thankful-father-61351
06/13/2023, 9:12 AMmelodic-train-1526
06/13/2023, 12:41 PMvictorious-lawyer-58417
06/13/2023, 3:45 PM/projects
project_a_flow.py
project_a/*
project_b_flow.py
project_b/*
project_c_flow.py
project_c/*
shared_utils/*victorious-lawyer-58417
06/13/2023, 3:46 PM/projects
project_a/project_a_flow.py
project_a/shared_utils -> ../shared_utils
project_a/*
project_b/project_b_flow.py
project_b/shared_utils -> ../shared_utils
project_b/*
project_c/project_c_flow.py
project_c/shared_utils -> ../shared_utils
project_c/*
shared_utils/*clean-megabyte-14460
04/01/2024, 5:42 PMthankful-father-61351
04/11/2024, 8:22 AMMetaflowPackage.path_tuples at runtime. This works very well for us and gives us full controle without having to implement a Metaflow plugins.clean-megabyte-14460
04/11/2024, 3:42 PMstraight-shampoo-11124
04/12/2024, 11:52 PMthankful-father-61351
04/21/2024, 9:09 PMit has worked pretty well thusfarSeems fine in the beginning.. but then.. all of this 😉 https://outerbounds-community.slack.com/archives/C020U025QJK/p1694719262967809
clean-megabyte-14460
04/23/2024, 2:30 PMthankful-father-61351
04/23/2024, 7:38 PMpath_tuples() function that Metaflow uses to find all the files to package. We do that by making sure this code is imported.
import itertools
import pathlib
from metaflow import metaflow_config
from metaflow import package
from metaflow.package import MetaflowPackage
INCLUDE_PATHS = [] # your shared code paths goes here
INCLUDE_SUFFIXES = [".py", ".yaml", ".yml", ".txt", ".cu", ".sh", ".json"]
def wrap_path_tuples(path_tuples_func):
def wrapper(self):
def list_files_in_paths(code_paths):
for code_path in code_paths:
for path in pathlib.Path(code_path).rglob("*"):
# Ignore hidden folders
if not str(path).startswith(".") and path.is_file() and path.suffix in INCLUDE_SUFFIXES:
yield str(path)
tuples = itertools.chain(
path_tuples_func(self),
((x, x) for x in list_files_in_paths(INCLUDE_PATHS)),
)
return tuples
return wrapper
package.DEFAULT_SUFFIXES_LIST = INCLUDE_SUFFIXES
metaflow_config.DEFAULT_PACKAGE_SUFFIXES = ",".join(INCLUDE_SUFFIXES)
MetaflowPackage.path_tuples = wrap_path_tuples(MetaflowPackage.path_tuples)
A bit hacky, but we have not had any issues with this and we had a million issues before 🙂