Esempio n. 1
0
 def test_list(self, arg: str,
               mock_workspace_operation: WorkspaceOperations) -> None:
     mock_workspace_operation.list(arg)
     if arg == "subscription":
         mock_workspace_operation._operation.list_by_subscription.assert_called_once(
         )
     else:
         mock_workspace_operation._operation.list_by_resource_group.assert_called_once(
         )
Esempio n. 2
0
    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)
Esempio n. 3
0
def mock_workspace_operation(mock_workspace_scope: WorkspaceScope,
                             mock_aml_services: Mock) -> WorkspaceOperations:
    yield WorkspaceOperations(workspace_scope=mock_workspace_scope,
                              service_client=mock_aml_services)
Esempio n. 4
0
 def test_delete(self, mock_workspace_operation: WorkspaceOperations,
                 randstr: str) -> None:
     mock_workspace_operation.delete(randstr)
     mock_workspace_operation._operation.begin_delete.assert_called_once()
Esempio n. 5
0
 def test_create_or_update(self,
                           mock_workspace_operation: WorkspaceOperations,
                           randstr: str) -> None:
     mock_workspace_operation.create_or_update(randstr)
     mock_workspace_operation._operation.begin_create_or_update.assert_called_once(
     )
Esempio n. 6
0
 def test_get(self, mock_workspace_operation: WorkspaceOperations,
              randstr: str) -> None:
     mock_workspace_operation.get(randstr)
     mock_workspace_operation._operation.get.assert_called_once()