Subject: Access to Flow Parameters within Flow att...
# dev-metaflow
c
Subject: Access to Flow Parameters within Flow attributes. Any suggestions? Best I can think of is to add the Flow parameters to new
params
fields in `current`:
Copy code
class ExampleFlow(FlowSpec):
    date_key = Parameter("date_key", default="2020-07-23")
    data_path = Parameter("data_path", default="<s3://aip-example-stage/data/>")

    @datasets.input(name="train_data", path=f"{current.params.data_path}/date={current.params.date_key}")
    @step
    def start(self):
        pass
1
a
hmm that's tricky, i think that f-string would be evaluated pretty early, when ExampleFlow class definition is loaded by the python interpreter
maybe we could have an option to provide a callable there, similar to how you can provide one for
default=
for Parameter, and that callable would be called by metaflow later
c
how would it have access to
self
? Or must we introduce a
current.param
field?
a
yea we'd have to pass it somehow
c
Do you know where in the metaflow code base the "params" are parsed? Where and how I could set
current.params
🙂
a
parameters.py
i believe
but you see the caveat here, right? metaflow first needs to load your Flow class definition to parse CLI args, including parameters
but that would make python evaluate
path=f"{current.params.data_path}/date={current.params.date_key}"
before params are even parsed, so a bit of a 🐔 🥚 problem here
c
hmm... this is tough: maybe evaluate later! without the f-string:
path="{current.params.data_path}/date={current.params.date_key}"
a
yeah that's probably the easiest/least invasive. The substitution can even be done by the
datasets.input
implementation in this case. That is, it would be part of
datasets.input
contract (not general Metaflow decorator contract) that you can a template string as a
path
parameter and it'll do parameter substitution there
c
then it can use
path="{self.params.data_path}"