How to use get_deployment method in localstack

Best Python code snippet using localstack_python

test_get_deployment.py

Source:test_get_deployment.py Github

copy

Full Screen

...7 @serve.deployment(name, version="1")8 def d(*args):9 return "1", os.getpid()10 with pytest.raises(KeyError):11 serve.get_deployment(name)12 d.deploy()13 val1, pid1 = ray.get(d.get_handle().remote())14 assert val1 == "1"15 del d16 d2 = serve.get_deployment(name)17 val2, pid2 = ray.get(d2.get_handle().remote())18 assert val2 == "1"19 assert pid2 == pid120def test_get_after_delete(serve_instance):21 name = "test"22 @serve.deployment(name, version="1")23 def d(*args):24 return "1", os.getpid()25 d.deploy()26 del d27 d2 = serve.get_deployment(name)28 d2.delete()29 del d230 with pytest.raises(KeyError):31 serve.get_deployment(name)32def test_deploy_new_version(serve_instance):33 name = "test"34 @serve.deployment(name, version="1")35 def d(*args):36 return "1", os.getpid()37 d.deploy()38 val1, pid1 = ray.get(d.get_handle().remote())39 assert val1 == "1"40 del d41 d2 = serve.get_deployment(name)42 d2.options(version="2").deploy()43 val2, pid2 = ray.get(d2.get_handle().remote())44 assert val2 == "1"45 assert pid2 != pid146def test_deploy_empty_version(serve_instance):47 name = "test"48 @serve.deployment(name)49 def d(*args):50 return "1", os.getpid()51 d.deploy()52 val1, pid1 = ray.get(d.get_handle().remote())53 assert val1 == "1"54 del d55 d2 = serve.get_deployment(name)56 d2.deploy()57 val2, pid2 = ray.get(d2.get_handle().remote())58 assert val2 == "1"59 assert pid2 != pid160def test_init_args(serve_instance):61 name = "test"62 @serve.deployment(name)63 class D:64 def __init__(self, val):65 self._val = val66 def __call__(self, *arg):67 return self._val, os.getpid()68 D.deploy("1")69 val1, pid1 = ray.get(D.get_handle().remote())70 assert val1 == "1"71 del D72 D2 = serve.get_deployment(name)73 D2.deploy()74 val2, pid2 = ray.get(D2.get_handle().remote())75 assert val2 == "1"76 assert pid2 != pid177 D2 = serve.get_deployment(name)78 D2.deploy("2")79 val3, pid3 = ray.get(D2.get_handle().remote())80 assert val3 == "2"81 assert pid3 != pid282def test_scale_replicas(serve_instance):83 name = "test"84 @serve.deployment(name)85 def d(*args):86 return os.getpid()87 def check_num_replicas(num):88 handle = serve.get_deployment(name).get_handle()89 assert len(set(ray.get([handle.remote() for _ in range(50)]))) == num90 d.deploy()91 check_num_replicas(1)92 del d93 d2 = serve.get_deployment(name)94 d2.options(num_replicas=2).deploy()95 check_num_replicas(2)96if __name__ == "__main__":97 import sys...

Full Screen

Full Screen

lib.py

Source:lib.py Github

copy

Full Screen

...16 return jwt.encode(m, secret, algorithm='HS256')17def error(error: Error):18 return {'error': error.type, 'message': error.message}, error.code19@cache.memoize(timeout=120)20def get_deployment(host, secret, owner_id, admin, challenge):21 aud = urlparse(host).hostname22 auth = generate_jwt(aud, secret, owner_id, admin)23 res = requests.get(24 f'{host}/deployments/{challenge}',25 headers={'authorization': f'Bearer {auth}'},26 timeout=TIMEOUT)27 return res.json(), res.status_code28def create_deployment(host, secret, owner_id, admin, challenge):29 aud = urlparse(host).hostname30 auth = generate_jwt(aud, secret, owner_id, admin)31 res = requests.post(32 f'{host}/deployments/{challenge}',33 json={},34 headers={'authorization': f'Bearer {auth}'},...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run localstack automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful