def setup_module(module): test_utils.torchserve_cleanup() response = requests.get('https://download.pytorch.org/models/' + MODEL_SFILE_NAME, allow_redirects=True) open(test_utils.MODEL_STORE + "/" + MODEL_SFILE_NAME, 'wb').write(response.content)
def setup_module(module): test_utils.torchserve_cleanup() response = requests.get( "https://torchserve.pytorch.org/mar_files/densenet161.mar", allow_redirects=True) open(test_utils.MODEL_STORE + "/densenet161.mar", 'wb').write(response.content)
def test_restart_torchserve_with_one_of_model_mar_removed(): """Validates that torchserve will fail to start in the following scenario: 1) We use a snapshot file to start torchserve. The snapshot contains reference to few model files 2) One of these model mar files are accidentally deleted from the model store""" # Register multiple models # 1st model test_utils.delete_model_store() test_utils.start_torchserve() requests.post( 'http://127.0.0.1:8081/models?url=https://torchserve.pytorch.org/mar_files/densenet161.mar' ) time.sleep(15) # 2nd model requests.post( 'http://127.0.0.1:8081/models?url=https://torchserve.pytorch.org/mar_files/mnist.mar' ) time.sleep(15) test_utils.stop_torchserve() # Start Torchserve test_utils.start_torchserve() response = requests.get('http://127.0.0.1:8081/models/') num_of_regd_models = len(json.loads(response.content)['models']) test_utils.stop_torchserve() # Now remove the registered model mar file (delete_mar_ fn) test_utils.delete_mar_file_from_model_store( model_store="/workspace/model_store", model_mar="densenet") # Start Torchserve with existing snapshot file containing reference to one of the model mar file # which is now missing from the model store snapshot_cfg = glob.glob('logs/config/*snap*.cfg')[1] test_utils.start_torchserve(snapshot_file=snapshot_cfg) try: response = requests.get('http://127.0.0.1:8081/models/') except: assert True, "Failed to start Torchserve as one of reqd model mar file is missing" else: assert False, "Something is not right!! Started Torchserve successfully with a " \ "reqd model mar file missing from the model store!!" finally: test_utils.torchserve_cleanup()
def teardown_module(module): test_utils.torchserve_cleanup()
def setup_module(module): test_utils.torchserve_cleanup() test_utils.start_torchserve()
def setup_module(module): test_utils.torchserve_cleanup() response = requests.get( "https://torchserve.s3.amazonaws.com/mar_files/mnist.mar", allow_redirects=True) open(test_utils.MODEL_STORE + "/mnist.mar", 'wb').write(response.content)