-
Notifications
You must be signed in to change notification settings - Fork 157
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
feat: add OptionalType
click parameter type
#1406
Merged
Merged
Changes from all commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
946b52e
fix: revise the incorrect parameter order
1dfa3b1
fix: add the missing argument
6bf92ab
fix: revise to support yaml formatted template
9fe278e
feat: implement OptionalType class
0e1d886
docs: add 1393.feature.md
741b44b
docs: write PR summary
2fb41f1
docs: supplement contents
3b03ed0
refactor: modify to support any types
27eaf98
docs: split news fregment into feature and fix
8c9ded2
refactor: add metavar
00d2d25
refactor: add underscore
18e82f2
fix: handle int type
7c336fd
fix: add missing keys in `params`
06c3eba
fix: modify default value
8821714
refactor: remove int type exception
3e251bd
fix: remove `scaling_group` key in `overwritten_param_check`
9643a14
Merge branch 'main' into fix/handle-undefined-click-argument-type
kimjinmyeong ec1a6f0
Merge branch 'main' into fix/handle-undefined-click-argument-type
88af73e
docs: update news fragments
0e48fed
Merge remote-tracking branch 'origin/main' into fix/handle-undefined-…
a7557f9
fix: rollback scaling_group check
491022a
refactor: modify dict access code
831df6d
docs: update news fragment
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Add `OptionalType` class as a new parameter type wrapper, allowing the client CLI to manage arguments of the `undefined` type. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Minor fixes to execute `backend.ai sesstpl create` and `backend.ai session create-from-template` commands |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -298,8 +298,8 @@ async def query_userinfo( | |
return await _query_userinfo( | ||
conn, | ||
request["user"]["uuid"], | ||
request["user"]["role"], | ||
request["keypair"]["access_key"], | ||
request["user"]["role"], | ||
request["user"]["domain_name"], | ||
request["keypair"]["resource_policy"], | ||
params["domain"] or request["user"]["domain_name"], | ||
|
@@ -384,10 +384,10 @@ async def _create(request: web.Request, params: dict[str, Any]) -> web.Response: | |
tx.AliasedKey(["name", "session_name", "clientSessionToken"], default=undefined) | ||
>> "session_name": UndefChecker | t.Regexp(r"^(?=.{4,64}$)\w[\w.-]*\w$", re.ASCII), | ||
tx.AliasedKey(["image", "lang"], default=undefined): UndefChecker | t.Null | t.String, | ||
tx.AliasedKey(["arch", "architecture"], default=DEFAULT_IMAGE_ARCH) | ||
>> "architecture": t.String, | ||
tx.AliasedKey(["type", "sessionType"], default="interactive") | ||
>> "session_type": tx.Enum(SessionTypes), | ||
Comment on lines
386
to
-390
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When a default value is set in here, the configuration value of the template gets overwritten by this default value. |
||
tx.AliasedKey(["arch", "architecture"], default=undefined) | ||
>> "architecture": t.String | UndefChecker, | ||
tx.AliasedKey(["type", "sessionType"], default=undefined) | ||
>> "session_type": tx.Enum(SessionTypes) | UndefChecker, | ||
tx.AliasedKey(["group", "groupName", "group_name"], default=undefined): ( | ||
UndefChecker | t.Null | t.String | ||
), | ||
|
@@ -470,7 +470,7 @@ async def create_from_template(request: web.Request, params: dict[str, Any]) -> | |
|
||
param_from_template = { | ||
"image": template["spec"]["kernel"]["image"], | ||
"architecture": template["spec"]["kernel"].get("architecture", DEFAULT_IMAGE_ARCH), | ||
"architecture": template["spec"]["kernel"]["architecture"], | ||
} | ||
if "domain_name" in template_info: | ||
param_from_template["domain"] = template_info["domain_name"] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -50,17 +50,18 @@ async def create(request: web.Request, params: Any) -> web.Response: | |
owner_access_key if owner_access_key != requester_access_key else "*", | ||
) | ||
root_ctx: RootContext = request.app["_root.context"] | ||
resp = [] | ||
async with root_ctx.db.begin() as conn: | ||
user_uuid, group_id, _ = await query_userinfo(request, params, conn) | ||
log.debug("Params: {0}", params) | ||
try: | ||
body = json.loads(params["payload"]) | ||
except json.JSONDecodeError: | ||
try: | ||
body = yaml.safe_load(params["payload"]) | ||
body = yaml.safe_load_all(params["payload"]) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||
except (yaml.YAMLError, yaml.MarkedYAMLError): | ||
raise InvalidAPIParameters("Malformed payload") | ||
for st in body["session_templates"]: | ||
for st in body: | ||
template_data = check_task_template(st["template"]) | ||
template_id = uuid.uuid4().hex | ||
name = st["name"] if "name" in st else template_data["metadata"]["name"] | ||
|
@@ -81,10 +82,12 @@ async def create(request: web.Request, params: Any) -> web.Response: | |
} | ||
) | ||
result = await conn.execute(query) | ||
resp = { | ||
"id": template_id, | ||
"user": user_uuid if isinstance(user_uuid, str) else user_uuid.hex, | ||
} | ||
resp.append( | ||
{ | ||
"id": template_id, | ||
"user": user_uuid if isinstance(user_uuid, str) else user_uuid.hex, | ||
} | ||
) | ||
assert result.rowcount == 1 | ||
return web.json_response(resp) | ||
|
||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If a
None
value is passed, thegroup
value gets overwritten withNone
, leading to an error.