Skip to main content

artifact type

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() 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