Skip to content

Modifying run tags alters run.created_at #2293

@dennismoe

Description

@dennismoe

Simple example from https://docs.metaflow.org/metaflow/basics#linear

LinearFlow
from metaflow import FlowSpec, step

class LinearFlow(FlowSpec):

    @step
    def start(self):
        self.my_var = 'hello world'
        self.next(self.a)

    @step
    def a(self):
        print('the data artifact is: %s' % self.my_var)
        self.next(self.end)

    @step
    def end(self):
        print('the data artifact is still: %s' % self.my_var)

if __name__ == '__main__':
    LinearFlow()

This behavior seems incorrect, as modifying tags even impacts flow.latest_successful_run, which should not be affected by metadata changes:

>>> from metaflow import *
>>> list(Metaflow())
[Flow('LinearFlow'), .....]
>>> Flow("LinearFlow")
Flow('LinearFlow')
>>> list(Flow("LinearFlow"))
[Run('LinearFlow/3'), Run('LinearFlow/2'), Run('LinearFlow/1')]
>>> Flow("LinearFlow").latest_successful_run
Run('LinearFlow/3')
>>> Run('LinearFlow/2').add_tag("status:deleted")
>>> Run('LinearFlow/2').tags
frozenset({'python_version:3.12.9', 'status:deleted', 'user:...', 'metaflow_version:2.14.3', 'runtime:dev'})
>>> list(Flow("LinearFlow"))
[Run('LinearFlow/2'), Run('LinearFlow/3'), Run('LinearFlow/1')]
>>> Flow("LinearFlow").latest_successful_run
Run('LinearFlow/2')
>>> Run('LinearFlow/1').created_at
datetime.datetime(2025, 2, 24, 19, 14, 49, 784000)
>>> Run('LinearFlow/1').add_tag("status:deleted")
>>> Run('LinearFlow/1').created_at
datetime.datetime(2025, 2, 24, 19, 18, 19, 313000)

The runs are sorted by run.created_at:

return iter(sorted(children, reverse=True, key=lambda x: x.created_at))

Am I missing something? I haven't found anything in the docs:

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions