Current - Operating a run
current object is used to inspect and manipulate the currently executing run. It is only available during flow execution, i.e. inside a
FlowSpec class and functions called from its steps. You can access the object simply by importing it:
from metaflow import current.
The attributes available in
current depend on the decorators assigned to the flow and the step where
current is used. Attributes that are always available are listed under Common Attributes below. Decorator-specific attributes are listed under the decorator name.
These attributes are always available in the
Returns True if called inside a running Flow, False otherwise.
You can use this property e.g. inside a library to choose the desired behavior depending on the execution context.
True if called inside a run, False otherwise.
The index of the task execution attempt.
This property returns 0 for the first attempt to execute the task. If the @retry decorator is used and the first attempt fails, this property returns the number of times the task was attempted prior to the current attempt.
The retry count.
The run ID of the original run this run was resumed from.
This property returns None for ordinary runs. If the run was started by the resume command, the property returns the ID of the original run.
You can use this property to detect if the run is resumed or not.
Run ID of the original run.
Pathspec of the current run, i.e. a unique identifier of the current task. The returned string follows this format:
The name of the user who started the run, if available.
These attributes are only available when the decorator is present.
The @project decorator exposes attributes related to the current deployment.
The name of the project assigned to this flow,
The flow name prefixed with the current project and branch. This name identifies the deployment on a production scheduler.
Flow name prefixed with project information.
The current branch, i.e.
--branch=X set during deployment.
True if the flow is deployed without a
--branch or a
True if the deployment does not correspond to a specific branch.
True if the flow is deployed with the
True if the flow is deployed in
The @card decorator exposes functions in
current that allow you to customize
the contents of cards using card components. For an overview of card-related APIs, see the API reference for cards.
Choose a specific card for manipulation.
When multiple @card decorators are present, you can add an
ID to distinguish between them,
@card(id=ID). This allows you
to add components to a specific card like this:
An object with
extend calls which allow you to
add components to the chosen card.
Specify components of the chosen card.
Instead of adding components to a card individually with
use this method to assign a list of components to a card, replacing the existing components:
current.card[ID] = [FirstComponent, SecondComponent]
List of card components to assign to this card.
Appends a component to the current card.
Card component to add to this card.