Skip to content

Commit aeb7f4c

Browse files
authored
feat: set title and description on project, workspace, job (#144)
* feat: set title and description on project, workspace, job Dedicated controller functions * refactor: set_desc -> set_description
1 parent 943de95 commit aeb7f4c

File tree

3 files changed

+54
-0
lines changed

3 files changed

+54
-0
lines changed

cryosparc/controllers/job.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,24 @@ def clear(self):
320320
"""
321321
self.model = self.cs.api.jobs.clear(self.project_uid, self.uid)
322322

323+
def set_title(self, title: str):
324+
"""
325+
Set the job title.
326+
327+
Args:
328+
title (str): New job title
329+
"""
330+
self.model = self.cs.api.jobs.set_title(self.project_uid, self.uid, title=title)
331+
332+
def set_description(self, desc: str):
333+
"""
334+
Set the job description. May include Markdown formatting.
335+
336+
Args:
337+
desc (str): New job description
338+
"""
339+
self.model = self.cs.api.jobs.set_description(self.project_uid, self.uid, description=desc)
340+
323341
def set_param(self, name: str, value: Any, **kwargs) -> bool:
324342
"""
325343
Set the given param name on the current job to the given value. Only

cryosparc/controllers/project.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,24 @@ def dir(self) -> PurePosixPath:
7373
"""Full path to project directory."""
7474
return PurePosixPathProperty(self.cs.api.projects.get_directory(self.uid))
7575

76+
def set_title(self, title: str):
77+
"""
78+
Set the project title.
79+
80+
Args:
81+
title (str): New project title
82+
"""
83+
self.model = self.cs.api.projects.set_title(self.uid, title=title)
84+
85+
def set_description(self, desc: str):
86+
"""
87+
Set the project description. May include Markdown formatting.
88+
89+
Args:
90+
desc (str): New project description
91+
"""
92+
self.model = self.cs.api.projects.set_description(self.uid, description=desc)
93+
7694
def find_workspaces(self, *, order: Literal[1, -1] = 1) -> Iterable[WorkspaceController]:
7795
"""
7896
Get all workspaces available in the current project.

cryosparc/controllers/workspace.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,24 @@ def refresh(self):
7070
self.model = self.cs.api.workspaces.find_one(self.project_uid, self.uid)
7171
return self
7272

73+
def set_title(self, title: str):
74+
"""
75+
Set the workspace title.
76+
77+
Args:
78+
title (str): New workspace title
79+
"""
80+
self.model = self.cs.api.workspaces.set_title(self.project_uid, self.uid, title=title)
81+
82+
def set_description(self, desc: str):
83+
"""
84+
Set the workspace description. May include Markdown formatting.
85+
86+
Args:
87+
desc (str): New workspace description
88+
"""
89+
self.model = self.cs.api.workspaces.set_description(self.project_uid, self.uid, description=desc)
90+
7391
def find_jobs(self, *, order: Literal[1, -1] = 1, **search: Unpack[JobSearch]) -> Iterable[JobController]:
7492
"""
7593
Search jobs in the current workspace.

0 commit comments

Comments
 (0)