hello folks, I'm trying to create a custom `StepDe...
# dev-metaflow
n
hello folks, I'm trying to create a custom
StepDecorator
and followed the guides from
metaflow-extensions-template
, also looked at examples in
metaflow-nflx-extensions
, but something is still missing as the registration fails with the following error message:
Copy code
metaflow_extensions: Found packages present at {'/home/daroczig/.local/share/virtualenvs/sc-resource-tracker-WkxmM6V1/lib/python3.13/site-packages/metaflow_extensions'}
metaflow_extensions: Found extension package 'resource-tracker' at '/home/daroczig/.local/share/virtualenvs/sc-resource-tracker-WkxmM6V1/lib/python3.13/site-packages/metaflow_extensions'...
metaflow_extensions:     Top-level 'resource_tracker' extends 'plugins' with config 'None'
metaflow_extensions:     Top-level 'resource_tracker' found config file 'metaflow_extensions.resource_tracker.plugins.mfextinit_resource_tracker'
Traceback (most recent call last):
  File "/home/daroczig/projects/sc-resource-tracker/examples/metaflow/1-single-step.py", line 4, in <module>
    from metaflow import Flow, FlowSpec, step
  File "/home/daroczig/.local/share/virtualenvs/sc-resource-tracker-WkxmM6V1/lib/python3.13/site-packages/metaflow/__init__.py", line 48, in <module>
    from metaflow.extension_support import (
    ...<7 lines>...
    )
  File "/home/daroczig/.local/share/virtualenvs/sc-resource-tracker-WkxmM6V1/lib/python3.13/site-packages/metaflow/extension_support/__init__.py", line 890, in <module>
    _all_packages, _pkgs_per_extension_point = _get_extension_packages()
                                               ~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/home/daroczig/.local/share/virtualenvs/sc-resource-tracker-WkxmM6V1/lib/python3.13/site-packages/metaflow/extension_support/__init__.py", line 666, in _get_extension_packages
    raise RuntimeError(
    ...<2 lines>...
    )
RuntimeError: Unresolved dependencies in 'metaflow_extensions': 'resource-tracker'
could someone please take a look at suggest what am I doing wrong? https://github.com/SpareCores/resource-tracker/tree/main/src/metaflow_extensions/resource_tracker/plugins
āœ… 1
r
Nothing comes to my mind immediately - can you run your flow with the flag
METAFLOW_DEBUG_EXT=1
and then show the outputs here?
n
thanks @rhythmic-controller-77489 šŸ™‡ the above was already run with
METAFLOW_DEBUG_EXT=1
šŸ˜… 2
r
Okay, taking a look
n
thanks a ton! there's an example flow in the
examples/metaflow
folder if you may have time to reproduce the problem
r
So, I removed the symlinks and moved things around a bit to have the following dir structure:
Copy code
mfextinit_track_resources.py
track_resources
ā”œā”€ā”€ __init__.py
ā”œā”€ā”€ resource_tracker
│   ā”œā”€ā”€ __init__.py
│   ā”œā”€ā”€ __pycache__
│   │   ā”œā”€ā”€ __init__.cpython-310.pyc
│   │   └── tracker.cpython-310.pyc
│   └── tracker.py
└── track_resources_decorator.py
mfextinit_resource_tracker.py
Copy code
STEP_DECORATORS_DESC = [
    ("track_resources", ".track_resources.track_resources_decorator.ResourceTrackerDecorator"),
]
And finally moved this import to inside the function, and it seems to have fixed the issue for me.
šŸ‘€ 1
Maybe just moving the import might fix the issue
n
thank you very much for taking a look! I highly appreciate it. I moved things around as you suggested, and commited at https://github.com/SpareCores/resource-tracker/commit/beaa54651ce2505a3a547d00e5a1c588809a5e90 the current folder structure (after building to filter out side effects from pyproject.toml config issues):
Copy code
metaflow_extensions
└── resource_tracker
    └── plugins
        ā”œā”€ā”€ mfextinit_resource_tracker.py
        ā”œā”€ā”€ __pycache__
        │   └── mfextinit_resource_tracker.cpython-313.pyc
        └── track_resources
            ā”œā”€ā”€ __init__.py
            ā”œā”€ā”€ __pycache__
            │   ā”œā”€ā”€ __init__.cpython-313.pyc
            │   └── track_resources_decorator.cpython-313.pyc
            ā”œā”€ā”€ resource_tracker
            │   ā”œā”€ā”€ __init__.py
            │   ā”œā”€ā”€ __pycache__
            │   │   ā”œā”€ā”€ __init__.cpython-313.pyc
            │   │   └── tracker.cpython-313.pyc
            │   └── tracker.py
            └── track_resources_decorator.py
also got rid of the symlink (as per above), and updated
mfextinit_resource_tracker.py
but still getting the same error when running
METAFLOW_DEBUG_EXT=1 python 1-single-step.py run
in the
examples/metaflow
folder šŸ˜ž
but if you still might have your working copy and could push it somewhere, I'd be super happy to take a look and figure out what did I miss above
r
I also modified the sample script to import the decorator as follows:
from metaflow import track_resources
āœ… 1
n
unfortunately, I'm still getting the same error
r
Tagging @hundreds-rainbow-67050 who might be able to help as well.
šŸ™‡ 1
n
oh, wow, I think I know facepalm these are the offending lines in my `pyproject.toml`:
Copy code
[project.optional-dependencies]
metaflow = ["metaflow"]
all = ["resource-tracker[metaflow]"]
sounds like a metaflow extension pkg should not have optional dependencies?
actually, just removing
Copy code
all = ["resource-tracker[metaflow]"]
fixes the problem
r
Ah great
n
any ideas, though, why is that causing a problem? 🤐