## lamindb.Transform

| class lamindb.Transform(key: str | None = None, kind: TransformKind | None = None, version: str | None = None, description: str | None = None, reference: str | None = None, reference_type: str | None = None, source_code: str | None = None, revises: Transform | None = None, skip_hash_lookup: bool = False) |
class lamindb.Transform(*db_args)

 Bases: "SQLRecord", "IsVersioned"

 Data transformations such as scripts, notebooks, functions, or
 pipelines.

 A "transform" can be a function, a script, a notebook, or a
 pipeline. If you execute a transform, you generate a run ("Run"). A
 run has inputs and outputs.

 Pipelines are typically created with a workflow manager (Nextflow,
 Snakemake, Prefect, Flyte, Dagster, redun, Airflow, ...).

 Transforms are versioned so that a given transform version maps on
 a given source code version.

 -[ Can I sync transforms to git? ]-

 If you set the environment variable "LAMINDB_SYNC_GIT_REPO" or set
 "ln.settings.sync_git_repo", a script-like transform is synced to
 its hashed state in a git repository upon calling "ln.track()":

 ln.settings.sync_git_repo = "https://github.com/laminlabs/lamindb"
 ln.track()

 If the hash isn't found in the git repository, an error is thrown.

 You can also create transforms that map pipelines via
 "Transform.from_git()".

 The definition of transforms and runs is consistent with the
 OpenLineage specification where a "transform" would be called a
 "job" and a "run" a "run".

 Parameters:
| * **key** -- "str | None = None" A short name or path-like |
 semantic key.

| * **kind** -- "TransformKind | None = "pipeline"" See |
 "TransformKind".

| * **version** -- "str | None = None" A version string. |

| * **description** -- "str | None = None" A description. |

| * **reference** -- "str | None = None" A reference, e.g., a URL. |

| * **reference_type** -- "str | None = None" A reference type, |
 e.g., 'url'.

| * **source_code** -- "str | None = None" Source code of the |
 transform.

| * **revises** -- "Transform | None = None" An old version of the |
 transform.

 * **skip_hash_lookup** -- "bool = False" Skip the hash lookup so
 that a new transform is created even if a transform with the
 same hash already exists.

 See also:

 "track()"
 Track a script or notebook run.

 "Run"
 Executions of transforms.

 -[ Notes ]-

 * Manage notebooks, scripts & workflows

 * Redun

 * Nextflow

 * Snakemake

 -[ Examples ]-

 Create a transform by running "ln.track()" in a notebook or a
 script:

 ln.track()

 Create a transform for a standalone function that acts as its own
 workflow:

 @ln.flow()
 def my_workflow():
 print("Hello, world!")

 Create a transform for a step in a workflow:

 @ln.step()
 def my_step():
 print("One step!")

 Create a transform for a pipeline:

 transform = ln.Transform(key="Cell Ranger", version="7.2.0", kind="pipeline").save()

 Create a transform by saving a Python or shell script or a notebook
 via the CLI:

 lamin save my_script.py
 lamin save my_script.sh
 lamin save my_notebook.ipynb

 property latest_run: Run

 The latest run of this transform.

 uid: str

 Universal id.

 key: str

 A name or "/"-separated path-like string.

 All transforms with the same key are part of the same version
 family.

| description: str | None |

 A description.

 kind: TransformKind

 A string indicating the kind of transform (default
 ""pipeline"").

 One of ""pipeline"", ""notebook"", ""script"", or ""function"".

| source_code: str | None |

 Source code of the transform.

| hash: str | None |

 Hash of the source code.

| reference: str | None |

 Reference for the transform, e.g., a URL.

| reference_type: str | None |

 Reference type of the transform, e.g., 'url'.

| environment: Artifact | None |

 An environment for executing the transform.

 created_at: datetime

 Time of creation of record.

 updated_at: datetime

 Time of last update to record.

 created_by: User

 Creator of record ← "created_transforms".

 ulabels: RelatedManager[ULabel]

 ULabel annotations of this transform ← "transforms".

 linked_in_records: RelatedManager[Record]

 This transform is linked in these records as a value ←
 "linked_transforms".

 predecessors: RelatedManager[Transform]

 Preceding transforms ← "successors".

 runs: Run

 Runs of this transform ← "transform".

 successors: RelatedManager[Transform]

 Subsequent transforms ← "predecessors".

 Allows defining succeeding transforms. Is *not* necessary for
 data lineage, which is tracked automatically whenever an
 artifact or collection serves as an input for a run.

 records: RelatedManager[Record]

 Records that annotate this transform ← "transforms".

 references: RelatedManager[Reference]

 Linked references ← "transforms".

 projects: RelatedManager[Project]

 Linked projects ← "transforms".

 ablocks: TransformBlock

 Attached blocks ← "transform".

 classmethod from_git(url, path, key=None, version=None, entrypoint=None, branch=None, description=None, skip_hash_lookup=False)

 Create a transform from a path in a git repository.

 Parameters:
 * **url** ("str") -- URL of the git repository.

 * **path** ("str") -- Path to the file within the repository.

| * **key** ("str" | "None", default: "None") -- Optional key |
 for the transform.

| * **version** ("str" | "None", default: "None") -- Optional |
 version tag to checkout in the repository.

| * **entrypoint** ("str" | "None", default: "None") -- One or |
 several optional comma-separated entrypoints for the
 transform.

| * **branch** ("str" | "None", default: "None") -- Optional |
 branch to checkout.

| * **description** ("str" | "None", default: "None") -- |
 Optional description for the transform.

 * **skip_hash_lookup** ("bool", default: "False") -- Skip the
 hash lookup so that a new transform is created even if a
 transform with the same hash already exists.

 Return type:
 "Transform"

 -[ Examples ]-

 Create from a Nextflow repo and auto-infer the commit hash from
 its latest version:

 transform = ln.Transform.from_git(
 url="https://github.com/openproblems-bio/task_batch_integration",
 path="main.nf"
 ).save()

 Create from a Nextflow repo and checkout a specific version:

 transform = ln.Transform.from_git(
 url="https://github.com/openproblems-bio/task_batch_integration",
 path="main.nf",
 version="v2.0.0"
 ).save()
 assert transform.version_tag == "v2.0.0"

 Create a *sliding transform* from a Nextflow repo's "dev"
 branch. Unlike a regular transform, a sliding transform doesn't
 pin a specific source code state, but adapts to whatever the
 referenced state on the branch is:

 transform = ln.Transform.from_git(
 url="https://github.com/openproblems-bio/task_batch_integration",
 path="main.nf",
 branch="dev",
 version="dev",
 ).save()

 -[ Notes ]-

 A regular transform pins a specific source code state through
 its commit hash:

 transform.source_code
 #> repo: https://github.com/openproblems-bio/task_batch_integration
 #> path: main.nf
 #> commit: 68eb2ecc52990617dbb6d1bb5c7158d9893796bb

 A sliding transform infers the source code state from a branch:

 transform.source_code
 #> repo: https://github.com/openproblems-bio/task_batch_integration
 #> path: main.nf
 #> branch: dev

 If an entrypoint is provided, it is added to the source code
 below the path, e.g.:

 transform.source_code
 #> repo: https://github.com/openproblems-bio/task_batch_integration
 #> path: main.nf
 #> entrypoint: myentrypoint
 #> commit: 68eb2ecc52990617dbb6d1bb5c7158d9893796bb

 Note that you can pass a comma-separated list of entrypoints to
 the "entrypoint" argument.

 view_lineage(with_successors=False, distance=5)

 View lineage of transforms.

 Note that this only accounts for manually defined predecessors
 and successors.

 Auto-generate lineage through inputs and outputs of runs is not
 included.