Skip to content

WIP: Add the ability to package more libraries #2269

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

Open
wants to merge 9 commits into
base: master
Choose a base branch
from

Conversation

romain-intel
Copy link
Contributor

No description provided.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the uv_environment now depends on read_info_file so the import needs to be updated. Be sure to rebase this at some point to catch such errors.

os.path.join(self.metaflow_dir.name, os.path.basename(INFO_FILE)),
os.path.join(
self.metaflow_dir.name,
os.path.basename(MetaFile.INFO_FILE.value),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MetaFile.INFO_FILE.value is just a filename so os.path.basename here seems unnecessary

@@ -162,6 +161,8 @@ def get_username():


def resolve_identity_as_tuple():
from metaflow.exception import MetaflowUnknownUser
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

was moving these imports necessary? no objections, just wondering.

@madhur-ob madhur-ob force-pushed the feat/extended_packaging branch from 8a3aabc to 51323cf Compare May 23, 2025 17:22
if _py_ver >= (3, 8):
from importlib import metadata
elif _py_ver >= (3, 7):
from metaflow._vendor.v3_7 import importlib_metadata as metadata
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

earlier, it was from metaflow._vendor import importlib_metadata as metadata
but we do have a separate folder for v3_7
thus, I changed the import to:
from metaflow._vendor.v3_7 import importlib_metadata as metadata

if _py_ver >= (3, 8):
from importlib import metadata
elif _py_ver >= (3, 7):
from metaflow._vendor.v3_7 import importlib_metadata as metadata
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same comment as before:

earlier, it was from metaflow._vendor import importlib_metadata as metadata
but we do have a separate folder for v3_7
thus, I changed the import to:
from metaflow._vendor.v3_7 import importlib_metadata as metadata

Now allows:
@Environment(vars=config_expr("..."))
  - This was broken since vars was a ConfigValue and not an updatable dictionary

@project(name=config_expr("get_my_name(cfg)"))
  - This was broken because when evaluating the config_expr, we did not
    consider the globals at the point of call but instead inside the file
    defining config_expr.

Tests are deployed internally.
  - fixes a case where configs and Runner/Deployer were not compatible due to
    configs not being processed in the same cwd

  - fixes an issue with constructing the config values (introduced in
    previous commit)

  - fixes the error message when both default and specified config files
    are not found
Previously something like:

RETRIES = config_expr("settings").retry

class MyFlow(FlowSpec):
  @retries(times=RETRIES)
  @step
  def start(self):
    ...

  @retries(times=RETRIES)
  @step
  def end(self):
    ...

would fail. Also, something like:

FOO = config_expr("settings").foo.bar
BAR = FOO.BAZ
BLAH = FOO.BAZ2

would also fail.

This fixes these issues by copying DelayEvaluator everytime and also
making the `__call__` function reentrant.
Two types of decorators are supported:
  - a "pure" Python decorator that allows you to execute something before
    and after a step. You also have the possibility of entirely skipping a step
    (which is a fairly requested feature)
  - mutators (Flow level or Step level). These mutators allow you to modify
    the flow/steps dynamically. This is particularly useful when put together
    with configs.

Still needs quite a few tests but it should be workable. A few features to try out:
  - You should be able to add mutators on a base flow spec class and have it
    work in a derived class
  - the add_decorator function on the MutableStep should take strings,
    actual MF decorators and user decorators
  - the add_decorator function on the MutableFlow should take strings
    and actual flow level decorators.
  - --with should work with any step level decorator (user defined including
    step mutators):
      - the name is the FQN for the class. It supports passing arguments as well
      - you can also use a shorter name provided that name is available *somewhere* where
        the flowspec is defined (either itself or one of its base classes)
  - mix and match decorators should work
  - the UserStepDecorator class has a init function that can take arguments
    if you want to build something a bit more fancy
  - the mutators also take arguments
  - config values can be used for any of those arguments (and of course can be
    used inside any of those functions)
@romain-intel romain-intel force-pushed the feat/extended_packaging branch from 51323cf to 98545b5 Compare May 29, 2025 08:36
@romain-intel romain-intel changed the base branch from master to fix/configs_func May 29, 2025 08:37
@romain-intel romain-intel marked this pull request as ready for review May 29, 2025 08:37
@savingoyal savingoyal mentioned this pull request May 29, 2025
Base automatically changed from fix/configs_func to master May 29, 2025 16:55
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

Successfully merging this pull request may close these issues.

4 participants