def test_get_by_id_model_same_dir(self): test_dir = "test-dir" datadriver = BlitzDBDALDriver("file", test_dir) dal = LocalDAL(datadriver) model1 = dal.model.create(Model(self.model_input_dict)) del datadriver del dal datadriver = BlitzDBDALDriver("file", test_dir) dal = LocalDAL(datadriver) model2 = dal.model.create(Model(self.model_input_dict)) del datadriver del dal datadriver = BlitzDBDALDriver("file", test_dir) dal = LocalDAL(datadriver) model3 = dal.model.create(Model(self.model_input_dict)) model1 = dal.model.get_by_id(model1.id) model2 = dal.model.get_by_id(model2.id) model3 = dal.model.get_by_id(model3.id) assert model1 assert model2 assert model3 shutil.rmtree(test_dir)
def test_get_by_id_model_new_driver_instance(self): model = self.dal.model.create(Model(self.model_input_dict)) # create new dal with new driver instance (success) new_driver_instance = BlitzDBDALDriver("file", self.temp_dir) new_dal_instance = LocalDAL(new_driver_instance) new_model_1 = new_dal_instance.model.get_by_id(model.id) assert new_model_1.id == model.id # create new dal instance with same driver (success) new_dal_instance = LocalDAL(self.datadriver) new_model_2 = new_dal_instance.model.get_by_id(model.id) assert new_model_2.id == model.id
def test_get_by_id_environment_new_driver_instance(self): environment = self.dal.environment.create(Environment(self.environment_input_dict)) # create new dal with new driver instance (success) new_driver_instance = BlitzDBDALDriver("file", self.temp_dir) new_dal_instance = LocalDAL(new_driver_instance) new_environment_1 = new_dal_instance.environment.get_by_id(environment.id) assert new_environment_1.id == environment.id # create new dal instance with same driver (success) new_dal_instance = LocalDAL(self.datadriver) new_environment_2 = new_dal_instance.environment.get_by_id(environment.id) assert new_environment_2.id == environment.id
def test_get_by_id_snapshot_new_driver_instance(self): snapshot = self.dal.snapshot.create(Snapshot(self.snapshot_input_dict)) # create new dal with new driver instance (fails) new_driver_instance = BlitzDBDALDriver("file", self.temp_dir) new_dal_instance = LocalDAL(new_driver_instance) new_snapshot_1 = new_dal_instance.snapshot.get_by_id(snapshot.id) assert new_snapshot_1.id == snapshot.id # create new dal instance with same driver (success) new_dal_instance = LocalDAL(self.datadriver) new_snapshot_2 = new_dal_instance.snapshot.get_by_id(snapshot.id) assert new_snapshot_2.id == snapshot.id
def test_get_by_id_user_new_driver_instance(self): user = self.dal.user.create(User(self.user_input_dict)) # create new dal with new driver instance (fails) new_driver_instance = BlitzDBDALDriver("file", self.temp_dir) new_dal_instance = LocalDAL(new_driver_instance) new_user_1 = new_dal_instance.user.get_by_id(user.id) assert new_user_1.id == user.id # create new dal instance with same driver (success) new_dal_instance = LocalDAL(self.datadriver) new_user_2 = new_dal_instance.user.get_by_id(user.id) assert new_user_2.id == user.id
def test_get_by_id_task_new_driver_instance(self): task = self.dal.task.create(Task(self.task_input_dict)) # create new dal with new driver instance (success) new_driver_instance = BlitzDBDALDriver("file", self.temp_dir) new_dal_instance = LocalDAL(new_driver_instance) new_task_1 = new_dal_instance.task.get_by_id(task.id) assert new_task_1.id == task.id # create new dal instance with same driver (success) new_dal_instance = LocalDAL(self.datadriver) new_task_2 = new_dal_instance.task.get_by_id(task.id) assert new_task_2.id == task.id
def test_get_by_id_code_new_driver_instance(self): code = self.dal.code.create(Code(self.code_input_dict)) # create new dal with new driver instance (success) new_driver_instance = BlitzDBDALDriver("file", self.temp_dir) new_dal_instance = LocalDAL(new_driver_instance) new_code_1 = new_dal_instance.code.get_by_id(code.id) assert new_code_1.id == code.id # create new dal instance with same driver (success) new_dal_instance = LocalDAL(self.datadriver) new_code_2 = new_dal_instance.code.get_by_id(code.id) assert new_code_2.id == code.id
def test_get_by_id_file_collection_new_driver_instance(self): file_collection = self.dal.file_collection.create( FileCollection(self.file_collection_input_dict)) # create new dal with new driver instance (success) new_driver_instance = BlitzDBDALDriver("file", self.temp_dir) new_dal_instance = LocalDAL(new_driver_instance) new_file_collection_1 = new_dal_instance.file_collection.get_by_id( file_collection.id) assert new_file_collection_1.id == file_collection.id # create new dal instance with same driver (success) new_dal_instance = LocalDAL(self.datadriver) new_file_collection_2 = new_dal_instance.file_collection.get_by_id( file_collection.id) assert new_file_collection_2.id == file_collection.id
def setup_method(self): # provide mountable tmp directory for docker tempfile.tempdir = "/tmp" if not platform.system( ) == "Windows" else None test_datmo_dir = os.environ.get('TEST_DATMO_DIR', tempfile.gettempdir()) self.temp_dir = tempfile.mkdtemp(dir=test_datmo_dir) self.driver_type = "blitzdb" self.driver_options = { "driver_type": "file", "connection_string": self.temp_dir } self.dal = LocalDAL(self.driver_type, self.driver_options) model_name = "model_1" model = self.dal.model.create(Model({"name": model_name})) self.environment_input_dict = { "model_id": model.id, "driver_type": "docker", "file_collection_id": "test_file_id", "definition_filename": "Dockerfile", "hardware_info": { "system": "macosx" }, "unique_hash": "slkdjfa23dk", "language": "python3" }
def setup_method(self): # provide mountable tmp directory for docker tempfile.tempdir = "/tmp" if not platform.system( ) == "Windows" else None test_datmo_dir = os.environ.get('TEST_DATMO_DIR', tempfile.gettempdir()) self.temp_dir = tempfile.mkdtemp(dir=test_datmo_dir) self.datadriver = BlitzDBDALDriver("file", self.temp_dir) self.dal = LocalDAL(self.datadriver) model_name = "model_1" model = self.dal.model.create(Model({"name": model_name})) session_name = "session_1" session = self.dal.session.create( Session({ "name": session_name, "model_id": model.id })) self.snapshot_input_dict = { "model_id": model.id, "session_id": session.id, "message": "my message", "code_id": "code_id", "environment_id": "environment_id", "file_collection_id": "file_collection_id", "config": { "test": 0.45 }, "stats": { "test": 0.98 } }
def setup_method(self): # provide mountable tmp directory for docker tempfile.tempdir = "/tmp" if not platform.system( ) == "Windows" else None test_datmo_dir = os.environ.get('TEST_DATMO_DIR', tempfile.gettempdir()) self.temp_dir = tempfile.mkdtemp(dir=test_datmo_dir) self.datadriver = BlitzDBDALDriver("file", self.temp_dir) self.dal = LocalDAL(self.datadriver) model_name = "model_1" model = self.dal.model.create(Model({"name": model_name})) session_name = "session_1" session = self.dal.session.create( Session({ "name": session_name, "model_id": model.id })) self.task_input_dict = { "model_id": model.id, "session_id": session.id, "command": "task_1", "start_time": datetime.utcnow(), "end_time": datetime.utcnow(), "duration": 0.004, }
def test_get_by_id_unknown_entity(self): exp_thrown = False dal = LocalDAL(self.driver_type, self.driver_options) try: dal.model.get_by_id("not_found") except EntityNotFound: exp_thrown = True except EntityCollectionNotFound: exp_thrown = True assert exp_thrown
def setup_class(self): # provide mountable tmp directory for docker tempfile.tempdir = "/tmp" if not platform.system( ) == "Windows" else None test_datmo_dir = os.environ.get('TEST_DATMO_DIR', tempfile.gettempdir()) self.temp_dir = tempfile.mkdtemp(dir=test_datmo_dir) self.datadriver = BlitzDBDALDriver("file", self.temp_dir) self.dal = LocalDAL(self.datadriver) model_name = "model_1" self.model_input_dict = {"name": model_name}
def setup_method(self): # provide mountable tmp directory for docker tempfile.tempdir = "/tmp" if not platform.system( ) == "Windows" else None test_datmo_dir = os.environ.get('TEST_DATMO_DIR', tempfile.gettempdir()) self.temp_dir = tempfile.mkdtemp(dir=test_datmo_dir) self.datadriver = BlitzDBDALDriver("file", self.temp_dir) self.dal = LocalDAL(self.datadriver) self.user_input_dict = { "name": "user_1", "email": "*****@*****.**", }
def setup_method(self): # provide mountable tmp directory for docker tempfile.tempdir = "/tmp" if not platform.system( ) == "Windows" else None test_datmo_dir = os.environ.get('TEST_DATMO_DIR', tempfile.gettempdir()) self.temp_dir = tempfile.mkdtemp(dir=test_datmo_dir) self.driver_type = "blitzdb" self.driver_options = { "driver_type": "file", "connection_string": self.temp_dir } self.dal = LocalDAL(self.driver_type, self.driver_options) model_name = "model_1" self.model_input_dict = {"name": model_name}
def setup_method(self): # provide mountable tmp directory for docker tempfile.tempdir = "/tmp" if not platform.system( ) == "Windows" else None test_datmo_dir = os.environ.get('TEST_DATMO_DIR', tempfile.gettempdir()) self.temp_dir = tempfile.mkdtemp(dir=test_datmo_dir) self.datadriver = BlitzDBDALDriver("file", self.temp_dir) self.dal = LocalDAL(self.datadriver) model_name = "model_1" model = self.dal.model.create(Model({"name": model_name})) self.code_input_dict = { "model_id": model.id, "driver_type": "git", "commit_id": "commit_id" }
def setup_class(self): # provide mountable tmp directory for docker tempfile.tempdir = "/tmp" if not platform.system( ) == "Windows" else None test_datmo_dir = os.environ.get('TEST_DATMO_DIR', tempfile.gettempdir()) self.temp_dir = tempfile.mkdtemp(dir=test_datmo_dir) self.datadriver = BlitzDBDALDriver("file", self.temp_dir) self.dal = LocalDAL(self.datadriver) model_name = "model_1" model = self.dal.model.create(Model({"name": model_name})) self.file_collection_input_dict = { "model_id": model.id, "driver_type": "local", "filehash": "myhash", "path": "test_path", }
def setup_method(self): # provide mountable tmp directory for docker tempfile.tempdir = "/tmp" if not platform.system( ) == "Windows" else None test_datmo_dir = os.environ.get('TEST_DATMO_DIR', tempfile.gettempdir()) self.temp_dir = tempfile.mkdtemp(dir=test_datmo_dir) self.driver_type = "blitzdb" self.driver_options = { "driver_type": "file", "connection_string": self.temp_dir } self.dal = LocalDAL(self.driver_type, self.driver_options) model_name = "model_1" model = self.dal.model.create(Model({"name": model_name})) self.task_input_dict = { "model_id": model.id, "command": "task_1", "start_time": datetime.utcnow(), "end_time": datetime.utcnow(), "duration": 0.004, }
def test_init(self): dal = LocalDAL(self.driver_type, self.driver_options) assert dal != None
def test_init(self): dal = LocalDAL(self.datadriver) assert dal != None