Hello, a question about the UI. I see that there a...
# ask-metaflow
r
Hello, a question about the UI. I see that there are a number of filters that are currently supported like
Project
,
Branch
, and
User
. Is it possible to use the
User
filter without having specified the
@project
decorator?
1
f
yup! you can use
User
without specifying any of the other filters, e.g. "show me all flow runs by this user". The project/branch data is optional and only available for flows using an
@project
decorator I'd recommend giving this a read if you're curious as well https://docs.metaflow.org/scaling/tagging
r
Hmm. I seem to be unable to filter my SFN executions by
User
. What value would this be populated with? In the definition of my SFN statemachine, I see the following added as environment variables to each step:
Copy code
METAFLOW_USER=SFN
METAFLOW_OWNER=my-user
USER=my-user
Are any of these representative of what we should be able to filter on?
b
Have a look at the
User
column of your list of runs. In this case I had a user called
sandbox
. Then I typed an
s
in the User field and it autocompleted.
r
Ah that explains things a bit. Do you know why this column would be empty then?
b
are you running your flows from the command line? If so can you check
whoami
?
r
We're kicking them off as step functions, making sure that we're setting
METAFLOW_USER
. Is that not sufficient?
u
There is logic within the UI that only displays the user if it is a "regular" user. If you click on a run and go to "task details" you will see a bunch of tags.... only if
"user:xxxxx"
exists, will xxxxx be displayed on the Metaflow UI.
f
Ah, yeah the
METAFLOW_USER=SFN
bit is due to how deployed SFNs can be triggered by other users/services. some extra context - https://outerbounds-community.slack.com/archives/C02116BBNTU/p1630535475071000
r
Circling back to this thread. How would one ensure that when an SFN execution is kicked off that the person who triggered it gets set properly? Specifically, where should
"user:xxxxx"
be set so that the UI actually presents something useful?
u
Thanks for the follow up. The GH issue for a polished solution for this is still pending. https://github.com/Netflix/metaflow/issues/681 However I can offer a workaround:
Copy code
from metaflow import FlowSpec, step, Parameter, current, Run
import os
class HelloFlow(FlowSpec):
  local_user = Parameter('local_user', default=os.environ.get('USER'))

  @step
  def start(self):
    if self.local_user:
      run = Run(f'{current.flow_name}/{current.run_id}')
      if os.environ.get('METAFLOW_RUNTIME_NAME') in ('argo-workflows', 'step-functions'):
        run.add_tag(f"triggered_by:{self.local_user}")
    ...
The outcome is that Metaflow UI will show the triggering USER as "trigger_by:USER" on the Metaflow UI, under user tags on the RHS. I know this is not ideal but hope this unblocks your team somewhat. Note while we don't expect the moving parts here to change soon (e.g. the METAFLOW_RUNTIME_NAME env var, local resolution of "USER" in Parameter), this workflow goes beyond our official public facing API / backward compatibility promises.