limited-agent-85591
11/29/2022, 8:38 PMclean-spring-46187
11/30/2022, 3:49 AMvictorious-lawyer-58417
11/30/2022, 7:18 AM@with_requirements which reads requirements from requirements.txt that has lines like this
numpy==1.20.3
matplotlib==3.4.2
this works with @batch and @kubernetes and production schedulers too, if you set an environment variable METAFLOW_PACKAGE_SUFFIXES=.txtvictorious-lawyer-58417
11/30/2022, 7:21 AM@with_requirements which uses @conda to read requirements from a config file, requirements.txtabundant-solstice-40600
12/01/2022, 3:21 AMvictorious-lawyer-58417
12/01/2022, 3:46 AMabundant-solstice-40600
12/01/2022, 4:33 AMthankful-megabyte-30444
12/04/2022, 6:20 PM@conda(libraries=CONFIG["requirements"])
While this works, the one common thing between both these solutions is that the location of requirements/config is hard coded in the flow. I was wondering if there is a way to specify this configuration file location. This is related to https://github.com/Netflix/metaflow/issues/431straight-shampoo-11124
12/05/2022, 3:05 AMopen('requirements.txt') with something like
open(os.environ['LIBRARIES_SPEC'])wooden-dusk-90720
12/06/2022, 8:05 PM==)victorious-lawyer-58417
12/06/2022, 8:07 PMvictorious-lawyer-58417
12/06/2022, 8:09 PMred-fountain-16335
12/09/2022, 2:15 PMpyproject.toml using Poetry 👍limited-agent-85591
12/15/2022, 6:33 PMthankful-megabyte-30444
12/26/2022, 4:25 AM@environment decorator, but it seems this can only be used to pass env variables to steps of a flow, rather than to the flow itself.
Basically I have a flow like this
config_file_loc = os.getenv("METAFLOW_CONFIG_FILE", str(pathlib.Path(__file__).parent / "configs" / "pricing_config.yaml"))
parsed = urlparse(config_file_loc, allow_fragments=False)
if parsed.scheme == "s3":
import boto3
s3 = boto3.client("s3")
CONFIG = yaml.safe_load(s3.get_object(Bucket=parsed.netloc, Key=parsed.path.lstrip("/"))["Body"].read())
else:
CONFIG = yaml.safe_load(open(config_file_loc, "r"))
class ExampleFlow(FlowSpec):
config_file = IncludeFile(
"config_file",
is_text=True,
default=os.getenv(
"METAFLOW_CONFIG_FILE",
str(pathlib.Path(__file__).parent / "configs" / "example_config.yaml"),
),
)
@card
@conda(pip=CONFIG["environment"])
@step
def start(self):
print("reading config")
self.config = yaml.safe_load(self.config_file)
I can trigger the flow like this
METAFLOW_CONFIG_FILE=/home/ubuntu/example_config.yaml python example_flow/run.py --environment=conda run
Both the param config_file which contains details other than the environment and the variable CONFIG that's used to set the conda decorator are set correctly based on the yaml file location defined in the env variable METAFLOW_CONFIG_FILE .
When step-functions create is run, do the @conda decorators get actual values based on the defaults or is the flow deployed as is? If it is the latter, how can I pass env variables to the step function at run-time (using the trigger command)?victorious-lawyer-58417
12/26/2022, 8:20 AMvictorious-lawyer-58417
12/26/2022, 8:21 AM