Skip to content

Commit

Permalink
chore: improve concurrency and division between layers
Browse files Browse the repository at this point in the history
  • Loading branch information
corban-beaird committed May 30, 2024
1 parent 1dc9f60 commit f9563a8
Show file tree
Hide file tree
Showing 26 changed files with 2,464 additions and 1,613 deletions.
11 changes: 8 additions & 3 deletions harness/determined/cli/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,13 @@ def format_experiment(e: bindings.v1Experiment) -> List[Any]:
def render_project(project: bindings.v1Project) -> None:
values = [
project.id,
project.key,
project.name,
project.description,
project.numExperiments,
project.numActiveExperiments,
]
PROJECT_HEADERS = ["ID", "Name", "Description", "# Experiments", "# Active Experiments"]
PROJECT_HEADERS = ["ID", "Key", "Name", "Description", "# Experiments", "# Active Experiments"]
render.tabulate_or_csv(PROJECT_HEADERS, [values], False)


Expand Down Expand Up @@ -100,7 +101,7 @@ def create_project(args: argparse.Namespace) -> None:
sess = cli.setup_session(args)
w = api.workspace_by_name(sess, args.workspace_name)
content = bindings.v1PostProjectRequest(
name=args.name, description=args.description, workspaceId=w.id
name=args.name, description=args.description, workspaceId=w.id, key=args.key
)
p = bindings.post_PostProject(sess, body=content, workspaceId=w.id).project
if args.json:
Expand Down Expand Up @@ -154,7 +155,9 @@ def delete_project(args: argparse.Namespace) -> None:
def edit_project(args: argparse.Namespace) -> None:
sess = cli.setup_session(args)
(w, p) = project_by_name(sess, args.workspace_name, args.project_name)
updated = bindings.v1PatchProject(name=args.new_name, description=args.description)
updated = bindings.v1PatchProject(
name=args.new_name, description=args.description, key=args.key
)
new_p = bindings.patch_PatchProject(sess, body=updated, id=p.id).project

if args.json:
Expand Down Expand Up @@ -247,6 +250,7 @@ def unarchive_project(args: argparse.Namespace) -> None:
cli.Arg("workspace_name", type=str, help="name of the workspace"),
cli.Arg("name", type=str, help="name of the project"),
cli.Arg("--description", type=str, help="description of the project"),
cli.Arg("--key", type=str, help="key of the project"),
cli.Arg("--json", action="store_true", help="print as JSON"),
],
),
Expand Down Expand Up @@ -309,6 +313,7 @@ def unarchive_project(args: argparse.Namespace) -> None:
cli.Arg("project_name", type=str, help="name of the project"),
cli.Arg("--new_name", type=str, help="new name of the project"),
cli.Arg("--description", type=str, help="description of the project"),
cli.Arg("--key", type=str, help="key of the project"),
cli.Arg("--json", action="store_true", help="print as JSON"),
],
),
Expand Down
3 changes: 2 additions & 1 deletion harness/determined/cli/workspace.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from determined.common.api import bindings, errors
from determined.common.experimental import workspace

PROJECT_HEADERS = ["ID", "Name", "Description", "# Experiments", "# Active Experiments"]
PROJECT_HEADERS = ["ID", "Key", "Name", "Description", "# Experiments", "# Active Experiments"]
WORKSPACE_HEADERS = [
"ID",
"Name",
Expand Down Expand Up @@ -121,6 +121,7 @@ def list_workspace_projects(args: argparse.Namespace) -> None:
values = [
[
p.id,
p.key,
p.name,
p.description,
p.n_experiments,
Expand Down
57 changes: 57 additions & 0 deletions harness/determined/common/api/bindings.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions harness/determined/common/experimental/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ class Project:
Attributes:
id: (int) The ID of the project.
key: (Mutable, str) The key of the project.
archived: (Mutable, bool) True if experiment is archived, else false.
description: (Mutable, str) The description of the project.
n_active_experiments: (int) The number of active experiments in the project.
Expand Down Expand Up @@ -45,6 +46,7 @@ def __init__(
self.notes: Optional[List[Dict[str, str]]] = None
self.workspace_id: Optional[int] = None
self.username: Optional[str] = None
self.key: Optional[str] = None

@classmethod
def _from_bindings(
Expand All @@ -64,6 +66,7 @@ def _hydrate(self, project_bindings: bindings.v1Project) -> None:
self.notes = [note.to_json() for note in project_bindings.notes]
self.workspace_id = project_bindings.workspaceId
self.username = project_bindings.username
self.key = project_bindings.key

def reload(self) -> None:
resp = bindings.get_GetProject(session=self._session, id=self.id)
Expand Down Expand Up @@ -93,6 +96,17 @@ def set_description(self, description: str) -> None:

self.description = resp.project.description

def set_key(self, key: str) -> None:
"""Set the project's key locally and on master.
Args:
key: The new key to set.
"""
patch_body = bindings.v1PatchProject(key=key)
resp = bindings.patch_PatchProject(session=self._session, id=self.id, body=patch_body)

self.key = resp.project.key

def set_name(self, name: str) -> None:
"""Set the project's name locally and on master.
Expand Down
2 changes: 2 additions & 0 deletions harness/determined/common/streams/wire.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit f9563a8

Please sign in to comment.