Esempio n. 1
0
    def _get_experiment_or_pipeline_resource_name(
        name: str, source: str, expected_schema: str
    ) -> str:
        """Get the full resource name of the Context representing an Experiment or Pipeline.

        Args:
            name (str):
                Name of the Experiment or Pipeline.
            source (str):
                Identify whether the this is an Experiment or a Pipeline.
            expected_schema (str):
                expected_schema identifies the expected schema used for Experiment or Pipeline.

        Returns:
            The full resource name of the Experiment or Pipeline Context.

        Raise:
            NotFound exception if experiment or pipeline does not exist.
        """

        context = _Context(resource_name=name)

        if context.schema_title != expected_schema:
            raise ValueError(
                f"Please provide a valid {source} name. {name} is not a {source}."
            )
        return context.resource_name
 def test_init_context_with_id(self, get_context_mock):
     aiplatform.init(project=_TEST_PROJECT, location=_TEST_LOCATION)
     context._Context(resource_name=_TEST_CONTEXT_ID,
                      metadata_store_id=_TEST_METADATA_STORE)
     get_context_mock.assert_called_once_with(name=_TEST_CONTEXT_NAME,
                                              retry=base._DEFAULT_RETRY)
 def test_init_context(self, get_context_mock):
     aiplatform.init(project=_TEST_PROJECT)
     context._Context(resource_name=_TEST_CONTEXT_NAME)
     get_context_mock.assert_called_once_with(name=_TEST_CONTEXT_NAME,
                                              retry=base._DEFAULT_RETRY)