Skip to main content

Artifact

A single input or output file for an action.

There is no .parent method on artifact, but in most cases cmd_args(my_artifact, parent = 1) can be used to similar effect.

Artifact.as_output

def Artifact.as_output(
) -> output_artifact

Returns a StarlarkOutputArtifact instance, or fails if the artifact is either an Artifact, or is a bound Artifact (You cannot bind twice)


Artifact.basename

Artifact.basename: str

The base name of this artifact. e.g. for an artifact at foo/bar, this is bar


Artifact.extension

Artifact.extension: str

The file extension of this artifact. e.g. for an artifact at foo/bar.sh, this is .sh. If no extension is present, "" is returned.


Artifact.is_source

Artifact.is_source: bool

Whether the artifact represents a source file


Artifact.owner

Artifact.owner: None | label

The Label of the rule that originally created this artifact. May also be None in the case of source files, or if the artifact has not be used in an action, or if the action was not created by a rule.


Artifact.project

def Artifact.project(
path: str,
/,
*,
hide_prefix: bool = False,
) -> artifact

Create an artifact that lives at path relative from this artifact.

For example, if artifact foo is a directory containing a file bar, then foo.project("bar") yields the file bar. It is possible for projected artifacts to hide the prefix in order to have the short name of the resulting artifact only contain the projected path, by passing hide_prefix = True to project().


Artifact.short_path

Artifact.short_path: str

The interesting part of the path, relative to somewhere in the output directory. For an artifact declared as foo/bar, this is foo/bar.


Artifact.with_associated_artifacts

def Artifact.with_associated_artifacts(
artifacts: list[artifact],
) -> artifact

Returns a StarlarkArtifact instance which is identical to the original artifact, but with potentially additional artifacts. The artifacts must be bound.


Artifact.without_associated_artifacts

def Artifact.without_associated_artifacts(
) -> artifact

Returns a StarlarkArtifact instance which is identical to the original artifact, except with no associated artifacts