def test_simple_data_notebook_directory(): bytes_content, f, t, zip_file_name = create_zip() with NotebookDirectory(data=bytes_content) as tmp: assert os.path.exists(tmp) is True assert len(os.listdir(tmp)) > 0 t.cleanup() os.remove(zip_file_name)
def test_single_file_bundle(): bytes_content, f, t, zip_file_name = create_zip() with BundleDirectory(bytes_content) as tmp: assert os.path.exists(tmp) is True f.close() t.cleanup() os.remove(zip_file_name)
def test_put_notebook_data(mocker): service = create_job_service(mocker) mocker.patch.object(service, 'submit_notebook_data') controller = DataController(service) data_bytes, _, temp_dir, zip_filename = create_zip() with flask.Flask("Test").app_context(): controller.put_notebook_data("test_workspace", "test_user", data_bytes=data_bytes) service.submit_notebook_data.assert_called_with("test_workspace", "test_user", t_any(str)) temp_dir.cleanup() os.remove(zip_filename)
def test_submit_notebook_missing_root(mocker): service = create_job_service(mocker) data_bytes, _, temp_dir, zip_filename = create_zip() with pytest.raises(InvalidBundleError, match="Missing root directory in source-code bundle"): with flask.Flask("Test").app_context(): controller = NotebookController(service) controller.submit_notebook("test_workspace", "test_user", data_bytes=data_bytes) temp_dir.cleanup() os.remove(zip_filename)
def test_deploy_inference_endpoint_missing_dockerfile(mocker): service = create_job_service(mocker) data_bytes, _, temp_dir, zip_filename = create_zip() with pytest.raises(InvalidBundleError, match="Missing root directory in source-code bundle"): with flask.Flask("Test").app_context(): controller = InferenceController(service) controller.deploy_inference_endpoint("test_workspace", "test_user", "test_model_id", data_bytes=data_bytes) temp_dir.cleanup() os.remove(zip_filename)
def test_put_features(mocker): service = create_job_service(mocker) mocker.patch.object(service, 'submit_training_data') mocker.patch.object(service, 'define_train_pipeline') mocker.patch.object(service, 'define_bundle_ingestion_pipeline') controller = DataController(service) data_bytes, temp_file, temp_dir, zip_filename = create_zip() hash_hex = build_hash(data_bytes) data_name = f"{os.path.split(temp_file.name)[-1]}:{hash_hex}" with flask.Flask("Test").app_context(): controller.put_features("test_workspace", "test_user", data_bytes=data_bytes) service.submit_training_data.assert_called_with("test_workspace", "test_user", t_any(str)) service.define_train_pipeline.assert_called_with("test_workspace", "test_user", data_name=data_name, cpu=None, memory=None, gpu=0) temp_dir.cleanup() os.remove(zip_filename)