Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix
Browse files Browse the repository at this point in the history
Michaelvll committed May 16, 2024
1 parent b93f1ac commit 87a7cc4
Showing 2 changed files with 14 additions and 11 deletions.
23 changes: 13 additions & 10 deletions sky/task.py
Original file line number Diff line number Diff line change
@@ -348,6 +348,18 @@ def from_yaml_config(
config: Dict[str, Any],
env_overrides: Optional[List[Tuple[str, str]]] = None,
) -> 'Task':
# More robust handling for 'envs': explicitly convert keys and values to
# str, since users may pass '123' as keys/values which will get parsed
# as int causing validate_schema() to fail.
envs = config.get('envs')
if envs is not None and isinstance(envs, dict):
for k, v in envs.items():
if v is not None:
envs[str(k)] = str(v)
else:
envs[str(k)] = None
common_utils.validate_schema(config, schemas.get_task_schema(),
'Invalid task YAML: ')
if env_overrides is not None:
# We must override env vars before constructing the Task, because
# the Storage object creation is eager and it (its name/source
@@ -364,16 +376,7 @@ def from_yaml_config(
with ux_utils.print_exception_no_traceback():
raise ValueError(
f'Environment variable {k!r} is None. Please set a '
'value in task YAML or with --env flag.')

# More robust handling for 'envs': explicitly convert keys and values to
# str, since users may pass '123' as keys/values which will get parsed
# as int causing validate_schema() to fail.
envs = config.get('envs')
if envs is not None and isinstance(envs, dict):
config['envs'] = {str(k): str(v) for k, v in envs.items()}
common_utils.validate_schema(config, schemas.get_task_schema(),
'Invalid task YAML: ')
'value for it in task YAML or with --env flag.')

# Fill in any Task.envs into file_mounts (src/dst paths, storage
# name/source).
2 changes: 1 addition & 1 deletion sky/utils/schemas.py
Original file line number Diff line number Diff line change
@@ -402,7 +402,7 @@ def get_task_schema():
'patternProperties': {
# Checks env keys are valid env var names.
'^[a-zA-Z_][a-zA-Z0-9_]*$': {
'type': 'string'
'type': ['string', 'null']
}
},
'additionalProperties': False,

0 comments on commit 87a7cc4

Please sign in to comment.