Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exception when rendering card on a flow expecting an optional Config property. #2191

Open
svpino opened this issue Dec 28, 2024 · 3 comments

Comments

@svpino
Copy link

svpino commented Dec 28, 2024

A flow with an optional Config property raises an exception when trying to generate a card.

Code to reproduce the issue:

from metaflow import Config, FlowSpec, card, step

class Sample(FlowSpec):
    config = Config("config", default=None)

    @card
    @step
    def start(self):
        self.next(self.end)

    @step
    def end(self):
        pass


if __name__ == "__main__":
    Sample()

Pipeline output with the exception text:

2024-12-28 11:53:51.402 [1735404831395269/start/1 (pid 97376)] Task is starting.
2024-12-28 11:53:51.655 [1735404831395269/start/1 (pid 97376)] Card render failed with error :
2024-12-28 11:53:51.793 [1735404831395269/start/1 (pid 97376)]
2024-12-28 11:53:51.793 [1735404831395269/start/1 (pid 97376)] Usage: sample.py [OPTIONS] COMMAND [ARGS]...
2024-12-28 11:53:51.793 [1735404831395269/start/1 (pid 97376)]
2024-12-28 11:53:51.793 [1735404831395269/start/1 (pid 97376)] Error: Could not find configuration 'kv.config' in INFO file
2024-12-28 11:53:51.793 [1735404831395269/start/1 (pid 97376)]
2024-12-28 11:53:51.793 [1735404831395269/start/1 (pid 97376)] Card render failed with error :
2024-12-28 11:53:51.811 [1735404831395269/start/1 (pid 97376)]
2024-12-28 11:53:51.811 [1735404831395269/start/1 (pid 97376)] Usage: sample.py [OPTIONS] COMMAND [ARGS]...
2024-12-28 11:53:51.811 [1735404831395269/start/1 (pid 97376)]
2024-12-28 11:53:51.811 [1735404831395269/start/1 (pid 97376)] Error: Could not find configuration 'kv.config' in INFO file
2024-12-28 11:53:51.811 [1735404831395269/start/1 (pid 97376)]
2024-12-28 11:53:51.812 [1735404831395269/start/1 (pid 97376)] Task finished successfully.
2024-12-28 11:53:51.815 [1735404831395269/end/2 (pid 97382)] Task is starting.
2024-12-28 11:53:51.949 [1735404831395269/end/2 (pid 97382)] Task finished successfully.
2024-12-28 11:53:51.949 Done!

This error doesn't happen if there's a default value specified for the Config. Unfortunately, that's not always possible so there's no obvious workaround at this point.

@savingoyal
Copy link
Collaborator

Thanks for the bug report. We are looking into it.

@romain-intel
Copy link
Contributor

Apologies for the delay -- I will fix it (I think I know what the issue is). I am curious, however, of your use case of a config with no default and not being required (ie: it can be None). We did discuss this internally (I have to go back and check) and am curious as to how you are planning to use it that way.

@svpino
Copy link
Author

svpino commented Dec 30, 2024

In this case, we have a flow capable of reading the configuration values from environment variables, but we want to add the ability to use a configuration file as well.

If a file is specified, we’ll read the settings from it. If not, we’ll use environment variables and default values.

Let me know if this answers your question and thanks for looking into this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants