Skip to content

Commit f2d2ab2

Browse files
authored
Fix issue with parsers not being compatible with extensions (#2320)
1 parent 71a5e8c commit f2d2ab2

File tree

3 files changed

+20
-6
lines changed

3 files changed

+20
-6
lines changed

metaflow/__init__.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -119,12 +119,11 @@ class and related decorators.
119119
# Decorators
120120
from .decorators import step, _import_plugin_decorators
121121

122-
# Config parsers
123-
from .plugins.pypi.parsers import (
124-
requirements_txt_parser,
125-
pyproject_toml_parser,
126-
conda_environment_yml_parser,
127-
)
122+
123+
# Parsers (for configs) for now
124+
from .plugins import _import_tl_plugins
125+
126+
_import_tl_plugins(globals())
128127

129128
# this auto-generates decorator functions from Decorator objects
130129
# in the top-level metaflow namespace

metaflow/extension_support/plugins.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,7 @@ def resolve_plugins(category, path_only=False):
198198
list(x.commands)[0] if len(x.commands) == 1 else "too many commands"
199199
),
200200
"runner_cli": lambda x: x.name,
201+
"tl_plugin": None,
201202
}
202203

203204

metaflow/plugins/__init__.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,12 @@
167167
),
168168
]
169169

170+
TL_PLUGINS_DESC = [
171+
("requirements_txt_parser", ".pypi.parsers.requirements_txt_parser"),
172+
("pyproject_toml_parser", ".pypi.parsers.pyproject_toml_parser"),
173+
("conda_environment_yml_parser", ".pypi.parsers.conda_environment_yml_parser"),
174+
]
175+
170176
process_plugins(globals())
171177

172178

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

216+
TL_PLUGINS = resolve_plugins("tl_plugin")
217+
210218
from .cards.card_modules import MF_EXTERNAL_CARDS
211219

212220
# Cards; due to the way cards were designed, it is harder to make them fit
@@ -251,3 +259,9 @@ def get_runner_cli_path():
251259
TestRefreshComponentCard,
252260
]
253261
merge_lists(CARDS, MF_EXTERNAL_CARDS, "type")
262+
263+
264+
def _import_tl_plugins(globals_dict):
265+
266+
for name, p in TL_PLUGINS.items():
267+
globals_dict[name] = p

0 commit comments

Comments
 (0)