Skip to content

Commit

Permalink
Fix issue with parsers not being compatible with extensions (#2320)
Browse files Browse the repository at this point in the history
  • Loading branch information
romain-intel authored Mar 2, 2025
1 parent 71a5e8c commit f2d2ab2
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 6 deletions.
11 changes: 5 additions & 6 deletions metaflow/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,12 +119,11 @@ class and related decorators.
# Decorators
from .decorators import step, _import_plugin_decorators

# Config parsers
from .plugins.pypi.parsers import (
requirements_txt_parser,
pyproject_toml_parser,
conda_environment_yml_parser,
)

# Parsers (for configs) for now
from .plugins import _import_tl_plugins

_import_tl_plugins(globals())

# this auto-generates decorator functions from Decorator objects
# in the top-level metaflow namespace
Expand Down
1 change: 1 addition & 0 deletions metaflow/extension_support/plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ def resolve_plugins(category, path_only=False):
list(x.commands)[0] if len(x.commands) == 1 else "too many commands"
),
"runner_cli": lambda x: x.name,
"tl_plugin": None,
}


Expand Down
14 changes: 14 additions & 0 deletions metaflow/plugins/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,12 @@
),
]

TL_PLUGINS_DESC = [
("requirements_txt_parser", ".pypi.parsers.requirements_txt_parser"),
("pyproject_toml_parser", ".pypi.parsers.pyproject_toml_parser"),
("conda_environment_yml_parser", ".pypi.parsers.conda_environment_yml_parser"),
]

process_plugins(globals())


Expand Down Expand Up @@ -207,6 +213,8 @@ def get_runner_cli_path():
if sys.version_info >= (3, 7):
DEPLOYER_IMPL_PROVIDERS = resolve_plugins("deployer_impl_provider")

TL_PLUGINS = resolve_plugins("tl_plugin")

from .cards.card_modules import MF_EXTERNAL_CARDS

# Cards; due to the way cards were designed, it is harder to make them fit
Expand Down Expand Up @@ -251,3 +259,9 @@ def get_runner_cli_path():
TestRefreshComponentCard,
]
merge_lists(CARDS, MF_EXTERNAL_CARDS, "type")


def _import_tl_plugins(globals_dict):

for name, p in TL_PLUGINS.items():
globals_dict[name] = p

0 comments on commit f2d2ab2

Please sign in to comment.