def test_create_or_update( self, mock_environment_operation: EnvironmentOperations, randstr: str) -> None: mock_environment_operation.create_or_update( environment_name=randstr, environment_version=randstr, file="./tests/test_configs/environment/environment_conda.yml", ) mock_environment_operation._version_operations.create_or_update.assert_called_once( )
def __init__( self, subscription_id: str, resource_group_name: str, default_workspace_name: str = None, base_url: str = MFE_BASE_URL, credential: ChainedTokenCredential = None, ): base_url, enforce_https = _get_developer_override(base_url) kwargs = {"enforce_https": enforce_https} self._workspace_scope = WorkspaceScope(subscription_id, resource_group_name, default_workspace_name) if credential: self._credential = credential else: self._credential = self._default_chained_credentials() self._service_client = AzureMachineLearningWorkspaces( subscription_id=self._workspace_scope._subscription_id, credential=self._credential, base_url=base_url ) self._operation_container = OperationsContainer() self._datastores = DatastoreOperations(self._workspace_scope, self._service_client, **kwargs) self._workspaces = WorkspaceOperations(self._workspace_scope, self._service_client) self._computes = ComputeOperations(self._workspace_scope, self._service_client) self._model = ModelOperations(self._workspace_scope, self._service_client, self._datastores) self._endpoints = EndpointOperations( self._workspace_scope, self._service_client, self._operation_container, self._credential, **kwargs ) self._data = DataOperations(self._workspace_scope, self._service_client, self._datastores, **kwargs) self._code = CodeOperations(self._workspace_scope, self._service_client, self._datastores, **kwargs) self._environments = EnvironmentOperations(self._workspace_scope, self._service_client, **kwargs) self._jobs = JobOperations(self._workspace_scope, self._service_client, self._operation_container, **kwargs) self._operation_container.add(OperationTypes.WORKSPACES, self._workspaces) self._operation_container.add(OperationTypes.COMPUTES, self._computes) self._operation_container.add(OperationTypes.DATASTORES, self._datastores) self._operation_container.add(OperationTypes.MODELS, self._model) self._operation_container.add(OperationTypes.ENDPOINTS, self._endpoints) self._operation_container.add(OperationTypes.DATASETS, self._data) self._operation_container.add(OperationTypes.CODES, self._code) self._operation_container.add(OperationTypes.JOBS, self._jobs) self._operation_container.add(OperationTypes.ENVIRONMENTS, self._environments)
def mock_environment_operation( mock_workspace_scope: WorkspaceScope, mock_aml_services: Mock) -> EnvironmentOperations: yield EnvironmentOperations(workspace_scope=mock_workspace_scope, service_client=mock_aml_services)
def test_get_latest_version( self, mock_environment_operation: EnvironmentOperations, randstr: str) -> None: mock_environment_operation.get_latest_version(randstr) mock_environment_operation._version_operations.list.assert_called_once( )
def test_list(self, mock_environment_operation: EnvironmentOperations) -> None: mock_environment_operation.list() mock_environment_operation._containers_operations.list.assert_called_once( )