MCPcopy
hub / github.com/SwanHubX/SwanLab / list_projects

Function list_projects

swanlab/cli/api/self_hosted.py:102–134  ·  view source on GitHub ↗

List all projects in the self-hosted instance.

(
    page_num: int,
    page_size: int,
    fetch_all: bool,
    search: Optional[str],
    creator: Optional[str],
    workspace: Optional[str],
    save_name: str,
    api: Api,
)

Source from the content-addressed store, hash-verified

100)
101@with_custom_host
102def list_projects(
103 page_num: int,
104 page_size: int,
105 fetch_all: bool,
106 search: Optional[str],
107 creator: Optional[str],
108 workspace: Optional[str],
109 save_name: str,
110 api: Api,
111):
112 """List all projects in the self-hosted instance."""
113 sh = api.self_hosted()
114 try:
115 projects = list(
116 sh.get_projects(
117 page=page_num,
118 size=page_size,
119 all=fetch_all,
120 search=search,
121 creator=creator,
122 group=workspace,
123 )
124 )
125 except ValueError as e:
126 payload = format_output(ApiResponseType(ok=False, errmsg=str(e)))
127 else:
128 if sh._errors:
129 payload = format_output(ApiResponseType(ok=False, errmsg="; ".join(sh._errors)))
130 else:
131 resp = ApiResponseType(ok=True, data={"list": projects})
132 payload = format_output(resp)
133 if save_name is not None:
134 save_output(orjson.dumps(payload, option=orjson.OPT_INDENT_2), name=save_name)
135
136
137@selfhosted_cli.command("summary")

Callers

nothing calls this directly

Calls 6

format_outputFunction · 0.90
ApiResponseTypeClass · 0.90
save_outputFunction · 0.90
self_hostedMethod · 0.80
get_projectsMethod · 0.80
joinMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…