broad-processor-92400
02/17/2025, 3:23 AMEnvironmentVarsRequest
but is blockedhappy-kitchen-89482
02/17/2025, 3:33 AMfresh-mechanic-68429
02/17/2025, 3:35 AMfresh-mechanic-68429
02/17/2025, 3:36 AMfresh-mechanic-68429
02/17/2025, 3:38 AMfresh-mechanic-68429
02/17/2025, 3:40 AMEnvironmentVarsRequest
working, I ended up finding SessionValues
and pulling the env vars like
complete_env = session_values[CompleteEnvironmentVars]
aws_env_vars = {
name: value
for name, value in complete_env.get_or_match("AWS_*")
}
But wasn't sure if thats something recommended or not
https://github.com/Zocdoc/pants/commit/f6c377b23b1adcf90c32cbb92941f4cd23e31e33#diff-9db7546d204ade92f3ca0eda531[âŚ]92d675364c143d7b15fe0a8c42f674c35happy-kitchen-89482
02/17/2025, 6:39 AMhappy-kitchen-89482
02/17/2025, 6:41 AMhappy-kitchen-89482
02/17/2025, 6:41 AMhappy-kitchen-89482
02/17/2025, 6:48 AMsession_values
like that, but you should be able to request CompleteEnvironmentVars
as an argument to your @rule?happy-kitchen-89482
02/17/2025, 6:50 AM@rule
async def download_from_s3(
request: S3DownloadFile, complete_env: CompleteEnvironmentVars, global_options: GlobalOptions
) -> Digest:
That seems to work. Or at least the solver completes.happy-kitchen-89482
02/17/2025, 6:53 AM@rule
async def download_from_s3(
request: S3DownloadFile, global_options: GlobalOptions
) -> Digest:
from botocore import auth, compat, exceptions # pants: no-infer-dep
env = await Get(EnvironmentVars, EnvironmentVarsRequest(["AWS_FOO", "AWS_BAR"]))
aws_credentials = await Get(
AWSCredentials,
AWSCredentialsRequest(env_vars=env)
)
happy-kitchen-89482
02/17/2025, 6:53 AMfresh-mechanic-68429
02/17/2025, 8:20 PMpants.backend.url_handlers.s3
to the pants.toml under backend_packages
otherwise that rule isn't actually registered (and the solver will complete)
[GLOBAL]
pants_version = "2.24.1"
backend_packages = [
"pants.backend.shell",
"pants.backend.url_handlers.s3",
]
plugins = [
'botocore==1.34.135'
]
fresh-mechanic-68429
02/18/2025, 2:05 AMCompleteEnvironmentVars
throws the same rule graph error.
I think your initial hunch was probably correct, "IIRC I think EnvironmentVarsRequest has to be used with an âEnvironmentAwareâ subsystem in scope"
These are file targets, which don't have the EnvironmentField on them.happy-kitchen-89482
02/18/2025, 5:43 AMSystemBinariesSubsystem.EnvironmentAware
, just to try out the hypothesis, did not helphappy-kitchen-89482
02/18/2025, 5:43 AMhappy-kitchen-89482
02/18/2025, 5:44 AMhappy-kitchen-89482
02/22/2025, 5:25 AMCompleteEnvironmentVars
requires an EnvironmentTarget
to be in scope. Usually one of those is provided by a target, but in this case there is no target in play. So the solver correctly fails.happy-kitchen-89482
02/22/2025, 5:27 AMfresh-mechanic-68429
02/22/2025, 5:52 AMso this is probably the right way to go.You're referring to
session_values[CompleteEnvironmentVars]
?happy-kitchen-89482
02/23/2025, 5:16 PMhappy-kitchen-89482
02/23/2025, 5:17 PMhappy-kitchen-89482
02/23/2025, 5:17 PMhappy-kitchen-89482
02/23/2025, 5:39 PMhappy-kitchen-89482
02/23/2025, 5:40 PMlocal_environment_name: ChosenLocalEnvironmentName
as an arg to your rulehappy-kitchen-89482
02/23/2025, 5:40 PMhappy-kitchen-89482
02/23/2025, 5:40 PMenv_vars = await Get(
EnvironmentVars,
{
EnvironmentVarsRequest([
"AWS_PROFILE",
"AWS_REGION",
"AWS_ACCESS_KEY_ID",
"AWS_SECRET_ACCESS_KEY",
"AWS_SESSION_TOKEN",
]): EnvironmentVarsRequest,
local_environment_name.val: EnvironmentName,
},
)
happy-kitchen-89482
02/23/2025, 5:40 PMGet
happy-kitchen-89482
02/23/2025, 5:41 PMfresh-mechanic-68429
02/26/2025, 5:00 AM