hallowed-byte-90517
09/12/2023, 5:04 PMdry-beach-38304
09/12/2023, 5:10 PMhallowed-byte-90517
09/12/2023, 5:17 PMdry-beach-38304
09/12/2023, 5:22 PMcalm-energy-78015
09/13/2023, 10:38 AMadd_to_package lifecycle hook. So during local development we can decorate a step with
@package_local_module(modules=["local_import"])
def step():
[...]dry-beach-38304
09/13/2023, 2:23 PMfast-pizza-24629
09/22/2023, 1:41 PMcalm-energy-78015
09/22/2023, 5:00 PMfrom metaflow.decorators import StepDecorator
class PackageLocalModules(StepDecorator):
name = "package_local_modules"
defaults = {"modules": []}
def add_to_package(self):
from importlib.util import find_spec
from pathlib import Path
package_files = []
for module in self.attributes["modules"]:
module_root = Path(find_spec(module).origin).parent
package_files.extend(module_root.glob("**/*"))
return package_files
we have some extra error handling, and functionality to ignore certain file/directory types, but that's the essential bit.
I'd previously said it was a flow decorator, but it is actually a step decorator. We have created a decorate_all_steps flow decorator that we use to only specify it once per flow.fast-pizza-24629
09/25/2023, 10:35 AM