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 task, i.e. a unique identifier of the current task. The returned string follows this format:
This is a shorthand to
The name of the user who started the run, if available.
Currently configured temporary directory.
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
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.
Appends many components to the current card.
Card components to add to this card.
Schedule the contents of this dynamic card to be refreshed soon.
Call this method after you have modified the list of components or
changed their contents with the components'
update method. This will
cause the card to update live while the task is executing.
Note that this method is rate-limited, determined by the
@card(refresh_interval) attribute. If you call this method more
frequently than what is allowed by
refresh_interval, some calls
are ignored causing the card to update more slowly.
It is advisable not to call this method more often than once
a second, which is the minimum allowed value for
data: dict, optional
Optional user-defined data to be passed to a custom card.
force: bool, optional
Force a full card re-render, not just a data update.