clean-school-46881
03/24/2023, 3:35 PM@environment decorator to set values, but I found that my personal credentials (in my local terminal environment) were available in Metaflow.victorious-lawyer-58417
03/24/2023, 3:45 PMos.environ in your own code (e.g in a custom decorator) prior to execution of any other custom code. Would that work?clean-school-46881
03/24/2023, 3:47 PMclean-school-46881
03/24/2023, 3:47 PMclean-school-46881
03/24/2023, 3:48 PMvictorious-lawyer-58417
03/24/2023, 3:51 PM@secretsvictorious-lawyer-58417
03/24/2023, 3:52 PMself.environ = os.environ optionallyvictorious-lawyer-58417
03/24/2023, 7:09 PM@strict_environment that makes sure you get a clean environment with only the env vars you specify + USER that Metaflow needs internallyvictorious-lawyer-58417
03/24/2023, 7:09 PMself.original_environmentclean-school-46881
03/27/2023, 3:18 PMclean-school-46881
03/27/2023, 4:43 PM@secrets . I was unable to make them play nicely together, regardless what order I put the decorators.victorious-lawyer-58417
03/27/2023, 5:10 PMgit subtree etc.
In addition or alternatively, you can use @conda to include packagesclean-school-46881
03/27/2023, 5:12 PMdependencies folder in the same repo (but in a parent directory) of my flow. Based on the documentation, this would not be present in the K8s containers for each step.clean-school-46881
03/27/2023, 5:13 PMpip installed it with the --editable argument, so it’s available in my venv where I’m triggering a Flow onto OBPclean-school-46881
03/27/2023, 5:14 PMclean-school-46881
03/27/2023, 5:15 PMvictorious-lawyer-58417
03/27/2023, 5:20 PMclean-school-46881
03/27/2023, 5:21 PMclean-school-46881
03/27/2023, 5:21 PMclean-school-46881
03/27/2023, 5:23 PMvictorious-lawyer-58417
03/27/2023, 5:25 PMif self.development_mode:
from experimental.my_package import my_module
else:
from subprocess import check_call
check_call([sys.executable, '-m', 'pip', 'install', 'my_package'])
from my_package import my_module
now if you had a directory structure like this
flow.py
experimental/
my_package/
my_module.py
you could use a parameter development_mode to choose between the experimental local version or installing a clean upstream version on the flyclean-school-46881
03/27/2023, 5:28 PMclean-school-46881
03/27/2023, 5:28 PMvictorious-lawyer-58417
03/27/2023, 5:30 PM@conda. Even if you don't install any Conda packages, you can just add an empty @conda and then pip install packages on the fly to get a clean environment.victorious-lawyer-58417
03/27/2023, 5:30 PM@pip)happy-wolf-7852
08/30/2024, 3:32 PM@conda_base(
libraries={
"numpy": "1.26.4",
"pandas": "2.2"
},
python="3.11.9"
)victorious-lawyer-58417
08/30/2024, 4:17 PM