示例#1
0
def test_append_project_tags(tmpdir):
    config = tmpdir.join(".sagemaker-code-config")
    config.write(
        '{"sagemakerProjectId": "proj-1234", "sagemakerProjectName": "proj-name"}'
    )
    working_dir = tmpdir.mkdir("sub")

    tags = _append_project_tags(None, working_dir)
    assert tags == [
        {
            "Key": "sagemaker:project-id",
            "Value": "proj-1234"
        },
        {
            "Key": "sagemaker:project-name",
            "Value": "proj-name"
        },
    ]

    tags = _append_project_tags([{"Key": "a", "Value": "b"}], working_dir)
    assert tags == [
        {
            "Key": "a",
            "Value": "b"
        },
        {
            "Key": "sagemaker:project-id",
            "Value": "proj-1234"
        },
        {
            "Key": "sagemaker:project-name",
            "Value": "proj-name"
        },
    ]
示例#2
0
    def create(
        self,
        role_arn: str,
        description: str = None,
        tags: List[Dict[str, str]] = None,
    ) -> Dict[str, Any]:
        """Creates a Pipeline in the Pipelines service.

        Args:
            role_arn (str): The role arn that is assumed by the pipeline to create step artifacts.
            description (str): A description of the pipeline.
            tags (List[Dict[str, str]]): A list of {"Key": "string", "Value": "string"} dicts as
                tags.

        Returns:
            A response dict from the service.
        """
        tags = _append_project_tags(tags)

        kwargs = self._create_args(role_arn, description)
        update_args(
            kwargs,
            Tags=tags,
        )
        return self.sagemaker_session.sagemaker_client.create_pipeline(
            **kwargs)
    def create(
        self,
        role_arn: str,
        description: str = None,
        tags: List[Dict[str, str]] = None,
        parallelism_config: ParallelismConfiguration = None,
    ) -> Dict[str, Any]:
        """Creates a Pipeline in the Pipelines service.

        Args:
            role_arn (str): The role arn that is assumed by the pipeline to create step artifacts.
            description (str): A description of the pipeline.
            tags (List[Dict[str, str]]): A list of {"Key": "string", "Value": "string"} dicts as
                tags.
            parallelism_config (Optional[ParallelismConfiguration]): Parallelism configuration
                that is applied to each of the executions of the pipeline. It takes precedence
                over the parallelism configuration of the parent pipeline.

        Returns:
            A response dict from the service.
        """
        tags = _append_project_tags(tags)
        kwargs = self._create_args(role_arn, description, parallelism_config)
        update_args(
            kwargs,
            Tags=tags,
        )
        return self.sagemaker_session.sagemaker_client.create_pipeline(
            **kwargs)