Skip to content

Commit

Permalink
Renamed value to key in return of parse_schema. Added key value to al…
Browse files Browse the repository at this point in the history
…l properties.
  • Loading branch information
WyvernIXTL committed Jun 2, 2024
1 parent c5eaaa0 commit 62cf93a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
5 changes: 3 additions & 2 deletions installation_instruction/installation_instruction.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,20 +82,21 @@ def parse_schema(self) -> dict:
"description": value.get("description", ""),
"type": value.get("type", "enum"),
"default": value.get("default", None),
"key": key,
}
if "enum" in value:
result["properties"][key]["enum"] = [
{
"title": e,
"value": e,
"key": e,
"description": "",
} for e in value["enum"]
]
elif type := "anyOf" if "anyOf" in value else "oneOf" if "oneOf" in value else None:
result["properties"][key]["enum"] = [
{
"title": c.get("title", c.get("const", "")),
"value": c.get("const", ""),
"key": c.get("const", ""),
"description": c.get("description", ""),
} for c in value[type]
]
Expand Down
10 changes: 6 additions & 4 deletions tests/test_installation_instruction.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,16 @@ def test_parse_schema(test_data_flags_options):
"description": "The package manager of your choosing.",
"default": "pip",
"type": "enum",
"key": "packager",
"enum": [
{
"title": "pip",
"value": "pip",
"key": "pip",
"description": ""
},
{
"title": "conda",
"value": "conda",
"key": "conda",
"description": ""
}
]
Expand All @@ -44,15 +45,16 @@ def test_parse_schema(test_data_flags_options):
assert schema["properties"]["compute_platform"] == {
"title": "Compute Platform",
"description": "Should your gpu or your cpu handle the task?",
"key": "compute_platform",
"enum": [
{
"title": "CUDA 11.8",
"value": "cu118",
"key": "cu118",
"description": ""
},
{
"title": "CUDA 12.1",
"value": "cu121",
"key": "cu121",
"description": "CUDA 12.1 is the latest version of CUDA."
}
],
Expand Down

0 comments on commit 62cf93a

Please sign in to comment.