Paweł Biernat
06/05/2024, 10:10 AMrun_deployment
or via UI. I wanted to change the default instance location from "eastus" to something else with run_deployment(..., job_variables={"location": "eastus2"})
but the instance is still created at "eastus". Is it possible to change the location on the run level at all? Or can I only change this on the deployment level?Paweł Biernat
06/05/2024, 11:20 AMjob_parameters
can only be used to set the predefined variables from the job template, defined for a given pool. In the default ACI pool there is no location variable and hence this gets ignored. So I added the variable to the template, updated the pool and now I can change the location on the deployment level via .deploy(..., job_parameters={"location": ...})
. So this works.
However, I still can't alter the location on per-run basis...Paweł Biernat
06/05/2024, 11:55 AMrun_deployment(..., job_variables={...})
or via UI.Paweł Biernat
06/06/2024, 7:48 AMif __name__ == "__main__":
test_flow.deploy(
name="test",
work_pool_name="local-docker-pool",
image="my-image",
push=False,
)
run_deployment(
name="test-flow/test",
job_variables={
"command": "echo 'A custom command!'",
"env": {
"TEST": "Hello, World!",
},
},
)
and the worker printed "A custom command!", which would be the expected behavior. More so, when I tried to use an incompatible data type for these fields the client returned an error on the run_deployment call
Response: {'detail': "Error creating flow run: Validation failed for field 'command'. Failure reason: ['echo', 'A custom command!'] is not valid under any of the given schemas"}
None of this happens when passing inconsistent arguments types for ACI push pool.Paweł Biernat
06/06/2024, 8:22 AMHenry Bruce
08/30/2024, 10:51 AMPaweł Biernat
08/30/2024, 12:56 PMclass AzureContainerWorkerRegion(AzureContainerWorker):
type: str = "azure-container-instance-region"
def __init__(
self,
*args,
name: Optional[str] = None,
limit: Optional[int] = None,
**kwargs,
):
if name is None:
raise ValueError("A name must be provided for the worker")
if "-" not in name:
raise ValueError(
"A region must be provided as part of the name with [base-name]-[region]"
)
self._region = name.split("-")[-1]
if self._region not in VALID_REGIONS:
raise ValueError(
f"Region {self._region} is not a valid Azure region. "
f"Valid regions are {', '.join(VALID_REGIONS)}."
)
if limit is None:
raise ValueError("A limit must be provided for the worker.")
super().__init__(*args, name=name, limit=limit, **kwargs)
# inject the specified region into the job template
async def _get_configuration(
self,
flow_run: "FlowRun",
) -> BaseJobConfiguration:
configuration = await super()._get_configuration(flow_run=flow_run)
configuration.arm_template["resources"][0]["location"] = self._region
<http://self._logger.info|self._logger.info>(f"Configured container group with location {self._region}")
pprint.pp(configuration)
return configuration
Then you just create one worker per region.Paweł Biernat
08/30/2024, 12:56 PMPaweł Biernat
08/30/2024, 12:57 PMHenry Bruce
08/30/2024, 2:08 PM