faint-zoo-41552
12/07/2023, 4:21 PMmain dir
|-dist
|-utility dir
+-projects dir
|-project 1
| +-flow directory
| project 2
+- flow directory
We want the flows to be able to use the library in the utility directory, and are looking at having the utilities being built as part of makefiles in each project directory. The root level makefile will create a python package and place it into the dist directory to be locally available.
What is the appropriate/correct/accepted method for having those utility functions get into the code that's sent to remote compute? Will the imports inside step functions "just work", or will we need to be using some internal pypi/conda distribution mechanism?dry-beach-38304
12/07/2023, 6:06 PMutility_dir from all your flow directories. The packaging will work appropriately. This won’t work “out of the box” though if there is an actual “build” step (ie: it’s not just python files). You can probably also make it work by including more file type (with the --package-suffixes option) but may not be the most convenient.
• you can package your utilities as a metaflow extension. It’s a bit of a simplified use of that mechanism but the idea is that if you publish your utilities package as a metaflow extension, if users have that installed when they run metaflow, it will get packaged up and sent over when executing remotely. This is not an officially supported path but I don’t see it changing (we use that extensively). If you have interest in that path, let me know and I can provide more details.
Generally though, this is not something we do very well. We’ve toyed with a few ideas but never really did anything yet. It’s something that is on our (distant) radar though. People mostly end up doing the first thing above with more advanced users probably delving into the second option (I know internally we have use cases of the second option).faint-zoo-41552
12/07/2023, 6:08 PMfaint-zoo-41552
12/07/2023, 6:22 PMdry-beach-38304
12/07/2023, 7:54 PMdry-beach-38304
12/07/2023, 7:58 PMmfextinit_org.py containing the single line: toplevel="org_toplevel"
• org_toplevel.py containing:
# Name of this customization
__mf_extensions__ = "org"
__mf_promote_submodules__ = ["my_utilities"]
__version__ = 0.1 # Or whatever version number you want here
Then just provide a my_utilities folder in metaflow_extensions/org and tada, users can now do: from <http://metaflow.my|metaflow.my>_utilities import foo or whatever.dry-beach-38304
12/07/2023, 7:59 PMfaint-zoo-41552
12/07/2023, 9:07 PMfaint-zoo-41552
12/07/2023, 9:08 PMdry-beach-38304
12/07/2023, 9:14 PMmain dir
|- dist
|- my_org_extensions
| + metaflow_extensions
| + org
|. + my_utilities
| - projects dir
...
and you would have to, in your makefile:
• build the metaflow_extensions package (and put it in dist)
• install it so that it is available and installed when you do myflow airflow … (or whatever you do)
For that last step, the basic thing is that this works if the package is “installed” (ie: when metaflow runs, it needs to find it). It can be installed as a package, in sys.path, etc but it needs to know about it.faint-zoo-41552
12/07/2023, 9:19 PMfaint-zoo-41552
12/07/2023, 9:19 PMdry-beach-38304
12/07/2023, 9:19 PMdry-beach-38304
12/07/2023, 9:20 PMfaint-zoo-41552
12/07/2023, 9:21 PMdry-beach-38304
12/07/2023, 9:21 PMfaint-zoo-41552
12/07/2023, 9:22 PMdry-beach-38304
12/07/2023, 9:23 PMdry-beach-38304
12/07/2023, 9:24 PMfaint-zoo-41552
12/07/2023, 9:25 PMdry-beach-38304
12/07/2023, 9:26 PMfaint-zoo-41552
12/07/2023, 9:26 PMdry-beach-38304
12/07/2023, 9:27 PMdry-beach-38304
12/07/2023, 9:27 PMdry-beach-38304
12/07/2023, 9:28 PMpip intall mygroup-metaflow and they are all set.faint-zoo-41552
12/07/2023, 9:28 PMdry-beach-38304
12/07/2023, 9:28 PMfaint-zoo-41552
12/07/2023, 9:28 PMdry-beach-38304
12/07/2023, 9:28 PMdry-beach-38304
12/07/2023, 9:30 PMfaint-zoo-41552
12/07/2023, 9:30 PMfaint-zoo-41552
12/07/2023, 9:31 PMdry-beach-38304
12/07/2023, 9:31 PMmetaflowfaint-zoo-41552
12/07/2023, 9:31 PMdry-beach-38304
12/07/2023, 9:32 PMfaint-zoo-41552
12/07/2023, 9:32 PMdry-beach-38304
12/07/2023, 9:32 PMfaint-zoo-41552
12/07/2023, 9:33 PMfaint-zoo-41552
12/07/2023, 9:33 PMmycompany-metaflow to make additional decorators, functions, etcfaint-zoo-41552
12/07/2023, 9:33 PMmycompany-metaflowfaint-zoo-41552
12/07/2023, 9:34 PMmycompany-metaflow is basically an inherited/extended version of metaflow enabled through the template projectfaint-zoo-41552
12/07/2023, 9:34 PMfaint-zoo-41552
12/07/2023, 9:34 PMfaint-zoo-41552
12/07/2023, 9:35 PMfaint-zoo-41552
12/07/2023, 9:35 PMdry-beach-38304
12/07/2023, 9:37 PMmycompany-metaflow. Publishes to company pypi
• team B who uses metaflow sets in their poetry toml file mycompany-metaflow instead of metaflow. THey get the benefit of all th shared stuff team A developed.faint-zoo-41552
12/07/2023, 9:37 PMfaint-zoo-41552
12/07/2023, 9:38 PMmycompany-metaflow ? Will there need to be more hoops to jump through so that the remote instance points to the pypi correctly?dry-beach-38304
12/07/2023, 9:40 PMdry-beach-38304
12/07/2023, 9:40 PMfaint-zoo-41552
12/07/2023, 9:40 PMdry-beach-38304
12/07/2023, 9:40 PMdry-beach-38304
12/07/2023, 9:41 PMfaint-zoo-41552
12/07/2023, 9:42 PMdry-beach-38304
12/07/2023, 9:46 PMfaint-zoo-41552
12/07/2023, 9:46 PMfaint-zoo-41552
12/07/2023, 9:47 PM___init___.py solution (and it is ludicrously hard to type that filename into slack)faint-zoo-41552
12/07/2023, 9:47 PMdry-beach-38304
12/07/2023, 9:48 PMfaint-zoo-41552
12/07/2023, 9:49 PMsys.path solution and now I feel sheepishfaint-zoo-41552
12/07/2023, 9:49 PMdry-beach-38304
12/07/2023, 9:49 PMfaint-zoo-41552
12/07/2023, 9:50 PM