metaflow icon indicating copy to clipboard operation
metaflow copied to clipboard

Modifying run tags alters `run.created_at`

Open dennismoe opened this issue 9 months ago • 2 comments

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:

https://github.com/Netflix/metaflow/blob/333eeeb5596f7ecb5db9a6fd98f7268c18bccb90/metaflow/client/core.py#L404

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

  • https://docs.metaflow.org/metaflow/client#common-properties
  • https://docs.metaflow.org/metaflow/client#properties-related-to-flows
  • https://docs.metaflow.org/scaling/tagging#tagging
  • https://docs.metaflow.org/metaflow/client#adding-removing-and-replacing-tags

dennismoe avatar Feb 24 '25 18:02 dennismoe

thanks! we are triaging this

savingoyal avatar Feb 24 '25 19:02 savingoyal

AFAICS this only happens in local mode - when METAFLOW_PROFILE is not set (unset)

run.created_at timestamps in AWS/S3 etc. do not change after modifying tags.

dennismoe avatar Feb 25 '25 17:02 dennismoe