Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clarify the input handling of session template CRUD API #3239

Open
achimnol opened this issue Dec 10, 2024 · 0 comments
Open

Clarify the input handling of session template CRUD API #3239

achimnol opened this issue Dec 10, 2024 · 0 comments
Labels
comp:manager Related to Manager component type:refactor Refactor codes or add tests.
Milestone

Comments

@achimnol
Copy link
Member

achimnol commented Dec 10, 2024

In lablup/backend.ai-manager#480, #1406, and #1668, the session template creation API became able to process only the yaml.safe_load_all()'s return value, which is a generator.

try:
body = json.loads(params["payload"])
except json.JSONDecodeError:
try:
body = yaml.safe_load_all(params["payload"])
except (yaml.YAMLError, yaml.MarkedYAMLError):
raise InvalidAPIParameters("Malformed payload")
for st in body:
template_data = check_task_template(st["template"])

In L64, it may crash with the json.loads() output as it would just return a dict, when the client submits a JSON data instead of YAML data. This is a potential bug.

Along with #3183, we need to clarify whether:

  • the API handler decomposes the input parameter object and applies individual validation to its parts, or
  • delegates the entire parameter interpretation to a structured schema (e.g., Pydantic).

The template schema itself should also allow unspecified value for the architecture field to support reusing the same template with multi-arch images in different host architectures (e.g., DGX-H100 and GH200 nodes).

cf) Currently the manager accepts as payload of the session template creation API:

template:
  api_version: 1  # actually ignored
  type: "taskTemplate"
  spec:
    kernel:
      ...
@achimnol achimnol added comp:manager Related to Manager component type:refactor Refactor codes or add tests. labels Dec 10, 2024
@achimnol achimnol added this to the 24.12 milestone Dec 10, 2024
@achimnol achimnol changed the title Clarify the input handling of session template creation API Clarify the input handling of session template CRUD API Dec 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
comp:manager Related to Manager component type:refactor Refactor codes or add tests.
Projects
None yet
Development

No branches or pull requests

1 participant