From 946b52e9b8f74ef7bc0b7d3bcaf974f96d519bad Mon Sep 17 00:00:00 2001 From: JinMyeong Kim Date: Thu, 20 Jul 2023 07:21:18 +0000 Subject: [PATCH 01/20] fix: revise the incorrect parameter order --- src/ai/backend/manager/api/session.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ai/backend/manager/api/session.py b/src/ai/backend/manager/api/session.py index 228a2692bf..c7a8857ba8 100644 --- a/src/ai/backend/manager/api/session.py +++ b/src/ai/backend/manager/api/session.py @@ -295,8 +295,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"], From 1dfa3b1bc20dca53c4ed2eb78c18dd13aa8136a1 Mon Sep 17 00:00:00 2001 From: JinMyeong Kim Date: Thu, 20 Jul 2023 08:21:08 +0000 Subject: [PATCH 02/20] fix: add the missing argument --- src/ai/backend/client/func/session.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/ai/backend/client/func/session.py b/src/ai/backend/client/func/session.py index 5d688838b8..7dd1869afe 100644 --- a/src/ai/backend/client/func/session.py +++ b/src/ai/backend/client/func/session.py @@ -358,6 +358,7 @@ async def create_from_template( enqueue_only: bool | Undefined = undefined, max_wait: int | Undefined = undefined, dependencies: Sequence[str] = None, # cannot be stored in templates + callback_url: str | Undefined = undefined, no_reuse: bool | Undefined = undefined, image: str | Undefined = undefined, mounts: Union[List[str], Undefined] = undefined, From 6bf92abf6c5dc9273a32fb4b853112286fb1cfc6 Mon Sep 17 00:00:00 2001 From: JinMyeong Kim Date: Thu, 20 Jul 2023 08:25:53 +0000 Subject: [PATCH 03/20] fix: revise to support yaml formatted template --- src/ai/backend/client/func/session_template.py | 3 ++- src/ai/backend/manager/api/session_template.py | 15 +++++++++------ 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/ai/backend/client/func/session_template.py b/src/ai/backend/client/func/session_template.py index ff77e64764..397ceeca17 100644 --- a/src/ai/backend/client/func/session_template.py +++ b/src/ai/backend/client/func/session_template.py @@ -32,7 +32,8 @@ async def create( rqst.set_json(body) async with rqst.fetch() as resp: response = await resp.json() - return cls(response["id"], owner_access_key=owner_access_key) + template_id = ", ".join(data["id"] for data in response) + return cls(template_id, owner_access_key=owner_access_key) @api_function @classmethod diff --git a/src/ai/backend/manager/api/session_template.py b/src/ai/backend/manager/api/session_template.py index 527fb47dfe..9294c49f69 100644 --- a/src/ai/backend/manager/api/session_template.py +++ b/src/ai/backend/manager/api/session_template.py @@ -50,6 +50,7 @@ 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) @@ -57,10 +58,10 @@ async def create(request: web.Request, params: Any) -> web.Response: body = json.loads(params["payload"]) except json.JSONDecodeError: try: - body = yaml.safe_load(params["payload"]) + body = yaml.safe_load_all(params["payload"]) 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) From 9fe278eca3fc3b04b44be404f6c894b4dbc1917f Mon Sep 17 00:00:00 2001 From: JinMyeong Kim Date: Thu, 20 Jul 2023 08:38:26 +0000 Subject: [PATCH 04/20] feat: implement OptionalType class --- src/ai/backend/client/cli/params.py | 13 +++++++++++++ src/ai/backend/client/cli/session.py | 28 +++++++++++++++++++++------- 2 files changed, 34 insertions(+), 7 deletions(-) diff --git a/src/ai/backend/client/cli/params.py b/src/ai/backend/client/cli/params.py index 7d80c2d43b..198518c47f 100644 --- a/src/ai/backend/client/cli/params.py +++ b/src/ai/backend/client/cli/params.py @@ -5,6 +5,8 @@ import click +from ..types import undefined + class ByteSizeParamType(click.ParamType): name = "byte" @@ -166,3 +168,14 @@ def convert(self, arg, param, ctx): return arg.split(",") except ValueError as e: self.fail(repr(e), param, ctx) + + +class OptionalType(click.ParamType): + name = "Optional Type Wrapper" + + def convert(self, value, param, ctx): + try: + if isinstance(value, (str, int)) or value == undefined: + return value + except ValueError as e: + self.fail(repr(e), param, ctx) diff --git a/src/ai/backend/client/cli/session.py b/src/ai/backend/client/cli/session.py index bbb5c24e68..eb31b81e2c 100644 --- a/src/ai/backend/client/cli/session.py +++ b/src/ai/backend/client/cli/session.py @@ -31,12 +31,13 @@ from ..session import AsyncSession, Session from ..types import Undefined, undefined from . import events -from .params import CommaSeparatedListType +from .params import CommaSeparatedListType, OptionalType from .pretty import print_done, print_error, print_fail, print_info, print_wait, print_warn from .run import format_stats, prepare_env_arg, prepare_mount_arg, prepare_resource_arg from .ssh import container_ssh_ctx list_expr = CommaSeparatedListType() +optional_type = OptionalType() @main.group() @@ -391,6 +392,7 @@ def _create_from_template_cmd(docs: str = None): "--name", "--client-token", metavar="NAME", + type=optional_type, default=undefined, help="Specify a human-readable session name. If not set, a random hex string is used.", ) @@ -399,6 +401,7 @@ def _create_from_template_cmd(docs: str = None): "--owner", "--owner-access-key", metavar="ACCESS_KEY", + type=optional_type, default=undefined, help="Set the owner of the target session explicitly.", ) @@ -418,11 +421,18 @@ def _create_from_template_cmd(docs: str = None): default=None, help="Let session to be started at a specific or relative time.", ) - @click.option("-i", "--image", default=undefined, help="Set compute_session image to run.") + @click.option( + "-i", + "--image", + type=optional_type, + default=undefined, + help="Set compute_session image to run.", + ) @click.option( "-c", "--startup-command", metavar="COMMAND", + type=optional_type, default=undefined, help="Set the command to execute for batch-type sessions.", ) @@ -434,7 +444,7 @@ def _create_from_template_cmd(docs: str = None): @click.option( "--max-wait", metavar="SECONDS", - type=int, + type=optional_type, default=undefined, help="The maximum duration to wait until the session starts.", ) @@ -469,7 +479,10 @@ def _create_from_template_cmd(docs: str = None): ) # extra options @click.option( - "--tag", type=str, default=undefined, help="User-defined tag string to annotate sessions." + "--tag", + type=optional_type, + default=undefined, + help="User-defined tag string to annotate sessions.", ) # resource spec @click.option( @@ -489,7 +502,7 @@ def _create_from_template_cmd(docs: str = None): @click.option( "--scaling-group", "--sgroup", - type=str, + type=optional_type, default=undefined, help=( "The scaling group to execute session. If not specified, " @@ -512,7 +525,7 @@ def _create_from_template_cmd(docs: str = None): @click.option( "--cluster-size", metavar="NUMBER", - type=int, + type=optional_type, default=undefined, help="The size of cluster in number of containers.", ) @@ -538,7 +551,8 @@ def _create_from_template_cmd(docs: str = None): "-g", "--group", metavar="GROUP_NAME", - default=None, + type=optional_type, + default=undefined, help=( "Group name where the session is spawned. " "User should be a member of the group to execute the code." From 0e1d886a8bea124f3e5e4e5400497db34771449f Mon Sep 17 00:00:00 2001 From: JinMyeong Kim Date: Thu, 20 Jul 2023 08:38:48 +0000 Subject: [PATCH 05/20] docs: add 1393.feature.md --- changes/1393.feature.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 changes/1393.feature.md diff --git a/changes/1393.feature.md b/changes/1393.feature.md new file mode 100644 index 0000000000..e69de29bb2 From 741b44b47ebf1f24c326f22b553c907344afff67 Mon Sep 17 00:00:00 2001 From: JinMyeong Kim Date: Thu, 20 Jul 2023 08:49:53 +0000 Subject: [PATCH 06/20] docs: write PR summary --- changes/1393.feature.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/changes/1393.feature.md b/changes/1393.feature.md index e69de29bb2..64802cec63 100644 --- a/changes/1393.feature.md +++ b/changes/1393.feature.md @@ -0,0 +1,2 @@ + Add `OptionalType` class to take the original type parameter (paramtype class or instance) and allow passing the `undefined` value as-is while enforcing the original logic in other cases. + Include minor fixes. \ No newline at end of file From 2fb41f1f333e56896ead51ca3647e1a6a505c78e Mon Sep 17 00:00:00 2001 From: JinMyeong Kim Date: Fri, 21 Jul 2023 01:01:41 +0000 Subject: [PATCH 07/20] docs: supplement contents --- changes/1393.feature.md | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/changes/1393.feature.md b/changes/1393.feature.md index 64802cec63..71b51583c4 100644 --- a/changes/1393.feature.md +++ b/changes/1393.feature.md @@ -1,2 +1,12 @@ - Add `OptionalType` class to take the original type parameter (paramtype class or instance) and allow passing the `undefined` value as-is while enforcing the original logic in other cases. - Include minor fixes. \ No newline at end of file +Add `OptionalType` class to handle `undefined` value +Revise to support for YAML format file when executing `backend.ai sesstpl create` +Revise the incorrect parameter order `_query_user_info` in `ai/backend/manager/api/session.py` +Add the missing argument `callback_url` in `src/ai/backend/client/func/session.py` + + + + + + + + \ No newline at end of file From 3b03ed0f3b33ab633157a279694ee28aed60641e Mon Sep 17 00:00:00 2001 From: JinMyeong Kim Date: Fri, 21 Jul 2023 06:50:28 +0000 Subject: [PATCH 08/20] refactor: modify to support any types --- src/ai/backend/client/cli/params.py | 10 +++++++--- src/ai/backend/client/cli/session.py | 20 +++++++++----------- 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/src/ai/backend/client/cli/params.py b/src/ai/backend/client/cli/params.py index 198518c47f..38a9132db7 100644 --- a/src/ai/backend/client/cli/params.py +++ b/src/ai/backend/client/cli/params.py @@ -173,9 +173,13 @@ def convert(self, arg, param, ctx): class OptionalType(click.ParamType): name = "Optional Type Wrapper" + def __init__(self, type) -> None: + super().__init__() + self.type = type + def convert(self, value, param, ctx): try: - if isinstance(value, (str, int)) or value == undefined: + if isinstance(value, self.type) or value == undefined: return value - except ValueError as e: - self.fail(repr(e), param, ctx) + except ValueError: + self.fail(f"{value!r} is not valid `{self.type_}` or `undefined`", param, ctx) diff --git a/src/ai/backend/client/cli/session.py b/src/ai/backend/client/cli/session.py index eb31b81e2c..def2756b92 100644 --- a/src/ai/backend/client/cli/session.py +++ b/src/ai/backend/client/cli/session.py @@ -37,7 +37,6 @@ from .ssh import container_ssh_ctx list_expr = CommaSeparatedListType() -optional_type = OptionalType() @main.group() @@ -392,7 +391,7 @@ def _create_from_template_cmd(docs: str = None): "--name", "--client-token", metavar="NAME", - type=optional_type, + type=OptionalType(str), default=undefined, help="Specify a human-readable session name. If not set, a random hex string is used.", ) @@ -401,7 +400,7 @@ def _create_from_template_cmd(docs: str = None): "--owner", "--owner-access-key", metavar="ACCESS_KEY", - type=optional_type, + type=OptionalType(str), default=undefined, help="Set the owner of the target session explicitly.", ) @@ -424,7 +423,7 @@ def _create_from_template_cmd(docs: str = None): @click.option( "-i", "--image", - type=optional_type, + type=OptionalType(str), default=undefined, help="Set compute_session image to run.", ) @@ -432,7 +431,7 @@ def _create_from_template_cmd(docs: str = None): "-c", "--startup-command", metavar="COMMAND", - type=optional_type, + type=OptionalType(str), default=undefined, help="Set the command to execute for batch-type sessions.", ) @@ -444,7 +443,7 @@ def _create_from_template_cmd(docs: str = None): @click.option( "--max-wait", metavar="SECONDS", - type=optional_type, + type=OptionalType(int), default=undefined, help="The maximum duration to wait until the session starts.", ) @@ -480,7 +479,7 @@ def _create_from_template_cmd(docs: str = None): # extra options @click.option( "--tag", - type=optional_type, + type=OptionalType(str), default=undefined, help="User-defined tag string to annotate sessions.", ) @@ -502,7 +501,7 @@ def _create_from_template_cmd(docs: str = None): @click.option( "--scaling-group", "--sgroup", - type=optional_type, + type=OptionalType(str), default=undefined, help=( "The scaling group to execute session. If not specified, " @@ -525,7 +524,7 @@ def _create_from_template_cmd(docs: str = None): @click.option( "--cluster-size", metavar="NUMBER", - type=optional_type, + type=OptionalType(int), default=undefined, help="The size of cluster in number of containers.", ) @@ -550,8 +549,7 @@ def _create_from_template_cmd(docs: str = None): @click.option( "-g", "--group", - metavar="GROUP_NAME", - type=optional_type, + type=OptionalType(str), default=undefined, help=( "Group name where the session is spawned. " From 27eaf98f29f555074b4c807a96361ff7cedf7d90 Mon Sep 17 00:00:00 2001 From: JinMyeong Kim Date: Fri, 21 Jul 2023 06:54:00 +0000 Subject: [PATCH 09/20] docs: split news fregment into feature and fix --- changes/1393.feature.md | 13 +------------ changes/1393.fix.md | 4 ++++ 2 files changed, 5 insertions(+), 12 deletions(-) create mode 100644 changes/1393.fix.md diff --git a/changes/1393.feature.md b/changes/1393.feature.md index 71b51583c4..cb52cc1c41 100644 --- a/changes/1393.feature.md +++ b/changes/1393.feature.md @@ -1,12 +1 @@ -Add `OptionalType` class to handle `undefined` value -Revise to support for YAML format file when executing `backend.ai sesstpl create` -Revise the incorrect parameter order `_query_user_info` in `ai/backend/manager/api/session.py` -Add the missing argument `callback_url` in `src/ai/backend/client/func/session.py` - - - - - - - - \ No newline at end of file +Add `OptionalType` class to handle `undefined` value \ No newline at end of file diff --git a/changes/1393.fix.md b/changes/1393.fix.md new file mode 100644 index 0000000000..7eee7bc6a7 --- /dev/null +++ b/changes/1393.fix.md @@ -0,0 +1,4 @@ +Minor fixes to execute `backend.ai sesstpl create` and `backend.ai session create-from-template` commands +* Revise to support for YAML format file when executing `backend.ai sesstpl create` +* Revise the incorrect parameter order in `_query_user_info` function +* Add the missing argument `callback_url` in `create_from_template` function \ No newline at end of file From 8c9ded2162f8a507b3a3b302665673aeee56e6a4 Mon Sep 17 00:00:00 2001 From: JinMyeong Kim Date: Fri, 21 Jul 2023 06:59:19 +0000 Subject: [PATCH 10/20] refactor: add metavar --- src/ai/backend/client/cli/session.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/ai/backend/client/cli/session.py b/src/ai/backend/client/cli/session.py index def2756b92..1a190d314e 100644 --- a/src/ai/backend/client/cli/session.py +++ b/src/ai/backend/client/cli/session.py @@ -549,6 +549,7 @@ def _create_from_template_cmd(docs: str = None): @click.option( "-g", "--group", + metavar="GROUP_NAME", type=OptionalType(str), default=undefined, help=( From 00d2d250e9491f821668bc3075c41ced1b87bed6 Mon Sep 17 00:00:00 2001 From: JinMyeong Kim Date: Fri, 21 Jul 2023 07:08:43 +0000 Subject: [PATCH 11/20] refactor: add underscore --- src/ai/backend/client/cli/params.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/ai/backend/client/cli/params.py b/src/ai/backend/client/cli/params.py index 38a9132db7..c8a95e1713 100644 --- a/src/ai/backend/client/cli/params.py +++ b/src/ai/backend/client/cli/params.py @@ -173,13 +173,13 @@ def convert(self, arg, param, ctx): class OptionalType(click.ParamType): name = "Optional Type Wrapper" - def __init__(self, type) -> None: + def __init__(self, type_: type) -> None: super().__init__() - self.type = type + self.type_ = type_ - def convert(self, value, param, ctx): + def convert(self, value: Any, param, ctx): try: - if isinstance(value, self.type) or value == undefined: + if isinstance(value, self.type_) or value is undefined: return value except ValueError: self.fail(f"{value!r} is not valid `{self.type_}` or `undefined`", param, ctx) From 18e82f29fc2ec8720a0f09c179c9c3a3c5706766 Mon Sep 17 00:00:00 2001 From: JinMyeong Kim Date: Mon, 24 Jul 2023 02:00:59 +0000 Subject: [PATCH 12/20] fix: handle int type --- src/ai/backend/client/cli/params.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/ai/backend/client/cli/params.py b/src/ai/backend/client/cli/params.py index c8a95e1713..c728f70784 100644 --- a/src/ai/backend/client/cli/params.py +++ b/src/ai/backend/client/cli/params.py @@ -179,7 +179,15 @@ def __init__(self, type_: type) -> None: def convert(self, value: Any, param, ctx): try: - if isinstance(value, self.type_) or value is undefined: + if value is None or value is undefined: return value + else: + try: + value = int(value) + self.type_ = int + except ValueError: + pass except ValueError: self.fail(f"{value!r} is not valid `{self.type_}` or `undefined`", param, ctx) + else: + return self.type_(value) From 7c336fdfdd17dfb2b65834fd6835a01cab35592f Mon Sep 17 00:00:00 2001 From: JinMyeong Kim Date: Mon, 24 Jul 2023 02:03:07 +0000 Subject: [PATCH 13/20] fix: add missing keys in `params` --- src/ai/backend/client/func/session.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/ai/backend/client/func/session.py b/src/ai/backend/client/func/session.py index 7dd1869afe..a242907978 100644 --- a/src/ai/backend/client/func/session.py +++ b/src/ai/backend/client/func/session.py @@ -469,6 +469,8 @@ async def create_from_template( "bootstrap_script": bootstrap_script, "enqueueOnly": enqueue_only, "maxWaitSeconds": max_wait, + "dependencies": dependencies, + "callbackURL": callback_url, "reuseIfExists": not no_reuse, "startupCommand": startup_command, "owner_access_key": owner_access_key, From 06c3eba1c23bfdc1b9e7f29f4ec6195df506a97d Mon Sep 17 00:00:00 2001 From: JinMyeong Kim Date: Mon, 24 Jul 2023 02:03:45 +0000 Subject: [PATCH 14/20] fix: modify default value --- src/ai/backend/manager/api/session.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/ai/backend/manager/api/session.py b/src/ai/backend/manager/api/session.py index c7a8857ba8..1617eb0c17 100644 --- a/src/ai/backend/manager/api/session.py +++ b/src/ai/backend/manager/api/session.py @@ -381,10 +381,10 @@ async def _create(request: web.Request, params: dict[str, Any]) -> web.Response: tx.AliasedKey(["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), + 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 ), From 882171417a498cd91745b24bf47008802023a0eb Mon Sep 17 00:00:00 2001 From: JinMyeong Kim Date: Tue, 25 Jul 2023 06:07:32 +0000 Subject: [PATCH 15/20] refactor: remove int type exception --- src/ai/backend/client/cli/params.py | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/src/ai/backend/client/cli/params.py b/src/ai/backend/client/cli/params.py index c728f70784..c9586596d3 100644 --- a/src/ai/backend/client/cli/params.py +++ b/src/ai/backend/client/cli/params.py @@ -181,13 +181,6 @@ def convert(self, value: Any, param, ctx): try: if value is None or value is undefined: return value - else: - try: - value = int(value) - self.type_ = int - except ValueError: - pass + return self.type_(value) except ValueError: self.fail(f"{value!r} is not valid `{self.type_}` or `undefined`", param, ctx) - else: - return self.type_(value) From 3e251bdd6bbbc8b90860c449235bb28643235068 Mon Sep 17 00:00:00 2001 From: JinMyeong Kim Date: Tue, 25 Jul 2023 07:50:31 +0000 Subject: [PATCH 16/20] fix: remove `scaling_group` key in `overwritten_param_check` --- src/ai/backend/manager/api/session.py | 1 - 1 file changed, 1 deletion(-) diff --git a/src/ai/backend/manager/api/session.py b/src/ai/backend/manager/api/session.py index 1617eb0c17..dc70d90ec5 100644 --- a/src/ai/backend/manager/api/session.py +++ b/src/ai/backend/manager/api/session.py @@ -257,7 +257,6 @@ def check_and_return(self, value: Any) -> object: t.Key("startup_command", default=None): t.Null | t.String, t.Key("bootstrap_script", default=None): t.Null | t.String, t.Key("owner_access_key", default=None): t.Null | t.String, - tx.AliasedKey(["scaling_group", "scalingGroup"], default=None): t.Null | t.String, tx.AliasedKey(["cluster_size", "clusterSize"], default=None): t.Null | t.Int[1:], tx.AliasedKey(["cluster_mode", "clusterMode"], default="single-node"): tx.Enum(ClusterMode), tx.AliasedKey(["starts_at", "startsAt"], default=None): t.Null | t.String, From 88af73e1036b4f81cdd88040b70a5f3fd88a1a92 Mon Sep 17 00:00:00 2001 From: JinMyeong Kim Date: Thu, 10 Aug 2023 01:17:58 +0900 Subject: [PATCH 17/20] docs: update news fragments --- changes/1393.feature.md | 2 +- changes/1393.fix.md | 3 --- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/changes/1393.feature.md b/changes/1393.feature.md index cb52cc1c41..4ba287dfcf 100644 --- a/changes/1393.feature.md +++ b/changes/1393.feature.md @@ -1 +1 @@ -Add `OptionalType` class to handle `undefined` value \ No newline at end of file +Add `OptionalType` class as a new param type wrapper to handle `undefined` value which takes the original type parameter and allow passing the undefined value as-is while enforcing the original logic in other cases diff --git a/changes/1393.fix.md b/changes/1393.fix.md index 7eee7bc6a7..c02810dba4 100644 --- a/changes/1393.fix.md +++ b/changes/1393.fix.md @@ -1,4 +1 @@ Minor fixes to execute `backend.ai sesstpl create` and `backend.ai session create-from-template` commands -* Revise to support for YAML format file when executing `backend.ai sesstpl create` -* Revise the incorrect parameter order in `_query_user_info` function -* Add the missing argument `callback_url` in `create_from_template` function \ No newline at end of file From a7557f9e771824db6c53ae1de1f4f03976c22df6 Mon Sep 17 00:00:00 2001 From: JinMyeong Kim Date: Wed, 16 Aug 2023 12:10:14 +0900 Subject: [PATCH 18/20] fix: rollback scaling_group check --- src/ai/backend/manager/api/session.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/ai/backend/manager/api/session.py b/src/ai/backend/manager/api/session.py index 75cc8af59a..438d80a0ae 100644 --- a/src/ai/backend/manager/api/session.py +++ b/src/ai/backend/manager/api/session.py @@ -260,6 +260,7 @@ def check_and_return(self, value: Any) -> object: t.Key("startup_command", default=None): t.Null | t.String, t.Key("bootstrap_script", default=None): t.Null | t.String, t.Key("owner_access_key", default=None): t.Null | t.String, + tx.AliasedKey(["scaling_group", "scalingGroup"], default=None): t.Null | t.String, tx.AliasedKey(["cluster_size", "clusterSize"], default=None): t.Null | t.Int[1:], tx.AliasedKey(["cluster_mode", "clusterMode"], default="single-node"): tx.Enum(ClusterMode), tx.AliasedKey(["starts_at", "startsAt"], default=None): t.Null | t.String, From 491022a04ab8c9d75194554f34550dc4836b4047 Mon Sep 17 00:00:00 2001 From: JinMyeong Kim Date: Wed, 16 Aug 2023 16:23:13 +0900 Subject: [PATCH 19/20] refactor: modify dict access code --- src/ai/backend/manager/api/session.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ai/backend/manager/api/session.py b/src/ai/backend/manager/api/session.py index 438d80a0ae..adcc2bb97b 100644 --- a/src/ai/backend/manager/api/session.py +++ b/src/ai/backend/manager/api/session.py @@ -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"] From 831df6d461d8cb963035da7064729e637668da09 Mon Sep 17 00:00:00 2001 From: JinMyeong Kim Date: Wed, 16 Aug 2023 17:03:33 +0900 Subject: [PATCH 20/20] docs: update news fragment --- changes/1393.feature.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/changes/1393.feature.md b/changes/1393.feature.md index 4ba287dfcf..4255243d5b 100644 --- a/changes/1393.feature.md +++ b/changes/1393.feature.md @@ -1 +1 @@ -Add `OptionalType` class as a new param type wrapper to handle `undefined` value which takes the original type parameter and allow passing the undefined value as-is while enforcing the original logic in other cases +Add `OptionalType` class as a new parameter type wrapper, allowing the client CLI to manage arguments of the `undefined` type.