incalculable-xylophone-18959
10/25/2024, 2:52 PMdry-beach-38304
10/25/2024, 3:21 PMincalculable-xylophone-18959
10/25/2024, 3:22 PMincalculable-xylophone-18959
10/25/2024, 3:22 PMdry-beach-38304
10/25/2024, 3:22 PMdry-beach-38304
10/25/2024, 3:23 PMincalculable-xylophone-18959
10/25/2024, 3:23 PMincalculable-xylophone-18959
10/25/2024, 3:23 PM@environment(
vars={
"AWS_DEFAULT_REGION": "us-gov-west-1",
"AWS_REGION": "us-gov-west-1",
"AWS_ACCESS_KEY_ID": os.environ["AWS_ACCESS_KEY_ID"],
"AWS_SECRET_ACCESS_KEY": os.environ["AWS_SECRET_ACCESS_KEY"],
"METAFLOW_S3_RETRY_COUNT": "0",
"NVIDIA_VISIBLE_DEVICES": "all"
}
incalculable-xylophone-18959
10/25/2024, 3:24 PMdry-beach-38304
10/25/2024, 3:27 PMos.environ[AWS_DEFAULT_REGION] = "us-gov-west-1
to have a similar effect. The ones that wouldn’t work with this approach are the ones that read from the current env (local) and push it out (so the ones for the AWS_ACCESS_KEY_ID
and the AWS_SECRET_ACCESS_KEY
. For that the @environment
is currently the solution (we don’t have a @environment_base
. You could do something like run --with environment:
(I’d have to check the exact syntax to specify them all) which would apply the environment decorator to every step.incalculable-xylophone-18959
10/25/2024, 3:30 PMx=os.environ[x]
in the decorator that pulls from the calling environment but if I were to set os.environ[x] = x
at the top of the metaflow script then that would set an environment variable in kubernetes.... is os.environ
local in both cases?dry-beach-38304
10/25/2024, 3:46 PMos.environ
is always local in the sense that it is the environment of whatever is calling the process. When you use it in the @enviornment
decorator, it reads from os.environ
on the local machine (when you do "AWS_ACCESS_KEY_ID": os.environ["AWS_ACCESS_KEY_ID"]
) and then on the remove machine, it basically does: os.environ["AWS_ACCESS_KEY_ID"] = <value read on local machine>
. So if you are always setting it to a constant, you don’t need the decorator. In your case though, you do need something like the decorator because you want to read a value form the local machine and then pass it to the remote one. Effectively, if it’s a constant, there is no need to “pass” it (since everyone can know about the constant) but if it is a dynamic value, then there is.