polyaxon 2.2.0rc0__py3-none-any.whl → 2.2.0rc1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -21,7 +21,11 @@ from clipped.utils.versions import compare_versions
21
21
  from urllib3.exceptions import HTTPError
22
22
 
23
23
  from polyaxon import settings
24
- from polyaxon._cli.dashboard import get_dashboard, get_dashboard_url
24
+ from polyaxon._cli.dashboard import (
25
+ get_dashboard,
26
+ get_dashboard_url,
27
+ get_project_subpath_url,
28
+ )
25
29
  from polyaxon._cli.errors import handle_cli_error, is_in_ce
26
30
  from polyaxon._cli.options import (
27
31
  OPTIONS_NAME,
@@ -286,7 +290,7 @@ def ls(
286
290
  else:
287
291
  Printer.warning(f"Skipping run {uid}, offline data not found.")
288
292
  else:
289
- owner, project_name = get_project_or_local(
293
+ owner, _, project_name = get_project_or_local(
290
294
  project or ctx.obj.get("project"), is_cli=True
291
295
  )
292
296
 
@@ -431,7 +435,7 @@ def get(ctx, project, uid, offline, path, output):
431
435
  sys.exit(1)
432
436
  run_data = RunConfigManager.read_from_path(offline_path)
433
437
  else:
434
- owner, project_name, run_uuid = get_project_run_or_local(
438
+ owner, team, project_name, run_uuid = get_project_run_or_local(
435
439
  project or ctx.obj.get("project"),
436
440
  uid,
437
441
  is_cli=True,
@@ -456,7 +460,9 @@ def get(ctx, project, uid, offline, path, output):
456
460
  )
457
461
  if output:
458
462
  run_url = get_dashboard_url(
459
- subpath="{}/{}/runs/{}".format(owner, project_name, run_uuid)
463
+ subpath="{}/runs/{}".format(
464
+ get_project_subpath_url(owner, team, project_name), run_uuid
465
+ )
460
466
  )
461
467
  config["url"] = run_url
462
468
  handle_output(config, output)
@@ -529,7 +535,7 @@ def delete(ctx, project, uid, yes, offline, path):
529
535
  return
530
536
 
531
537
  # Resume normal flow
532
- owner, project_name, run_uuid = get_project_run_or_local(
538
+ owner, _, project_name, run_uuid = get_project_run_or_local(
533
539
  project or ctx.obj.get("project"),
534
540
  uid or ctx.obj.get("run_uuid"),
535
541
  is_cli=True,
@@ -624,7 +630,7 @@ def update(ctx, project, uid, name, description, tags, offline, path):
624
630
  )
625
631
  sys.exit(1)
626
632
  else:
627
- owner, project_name, run_uuid = get_project_run_or_local(
633
+ owner, _, project_name, run_uuid = get_project_run_or_local(
628
634
  project or ctx.obj.get("project"),
629
635
  uid or ctx.obj.get("run_uuid"),
630
636
  is_cli=True,
@@ -663,7 +669,7 @@ def approve(ctx, project, uid):
663
669
  \b
664
670
  $ polyaxon ops approve --uid 8aac02e3a62a4f0aaa257c59da5eab80
665
671
  """
666
- owner, project_name, run_uuid = get_project_run_or_local(
672
+ owner, _, project_name, run_uuid = get_project_run_or_local(
667
673
  project or ctx.obj.get("project"),
668
674
  uid or ctx.obj.get("run_uuid"),
669
675
  is_cli=True,
@@ -710,7 +716,7 @@ def stop(ctx, project, uid, yes):
710
716
  \b
711
717
  $ polyaxon ops stop --uid 8aac02e3a62a4f0aaa257c59da5eab80
712
718
  """
713
- owner, project_name, run_uuid = get_project_run_or_local(
719
+ owner, _, project_name, run_uuid = get_project_run_or_local(
714
720
  project or ctx.obj.get("project"),
715
721
  uid or ctx.obj.get("run_uuid"),
716
722
  is_cli=True,
@@ -762,7 +768,7 @@ def skip(ctx, project, uid, yes):
762
768
  \b
763
769
  $ polyaxon ops skip --uid 8aac02e3a62a4f0aaa257c59da5eab80
764
770
  """
765
- owner, project_name, run_uuid = get_project_run_or_local(
771
+ owner, _, project_name, run_uuid = get_project_run_or_local(
766
772
  project or ctx.obj.get("project"),
767
773
  uid or ctx.obj.get("run_uuid"),
768
774
  is_cli=True,
@@ -866,7 +872,7 @@ def restart(
866
872
  if polyaxonfile:
867
873
  content = OperationSpecification.read(polyaxonfile, is_preset=True).to_json()
868
874
 
869
- owner, project_name, run_uuid = get_project_run_or_local(
875
+ owner, _, project_name, run_uuid = get_project_run_or_local(
870
876
  project or ctx.obj.get("project"),
871
877
  uid or ctx.obj.get("run_uuid"),
872
878
  is_cli=True,
@@ -951,7 +957,7 @@ def resume(
951
957
  if polyaxonfile:
952
958
  content = OperationSpecification.read(polyaxonfile, is_preset=True).to_json()
953
959
 
954
- owner, project_name, run_uuid = get_project_run_or_local(
960
+ owner, _, project_name, run_uuid = get_project_run_or_local(
955
961
  project or ctx.obj.get("project"),
956
962
  uid or ctx.obj.get("run_uuid"),
957
963
  is_cli=True,
@@ -994,7 +1000,7 @@ def invalidate(ctx, project, uid):
994
1000
  \b
995
1001
  $ polyaxon ops invalidate --uid 8aac02e3a62a4f0aaa257c59da5eab80
996
1002
  """
997
- owner, project_name, run_uuid = get_project_run_or_local(
1003
+ owner, _, project_name, run_uuid = get_project_run_or_local(
998
1004
  project or ctx.obj.get("project"),
999
1005
  uid or ctx.obj.get("run_uuid"),
1000
1006
  is_cli=True,
@@ -1183,7 +1189,7 @@ def execute(ctx, project, uid, executor):
1183
1189
  message="Operation failed.\n{}".format(result["message"]),
1184
1190
  )
1185
1191
 
1186
- owner, project_name, run_uuid = get_project_run_or_local(
1192
+ owner, _, project_name, run_uuid = get_project_run_or_local(
1187
1193
  project or ctx.obj.get("project"),
1188
1194
  uid or ctx.obj.get("run_uuid"),
1189
1195
  is_cli=True,
@@ -1307,7 +1313,7 @@ def statuses(ctx, project, uid, watch, offline, path):
1307
1313
  sys.exit(1)
1308
1314
  return
1309
1315
 
1310
- owner, project_name, run_uuid = get_project_run_or_local(
1316
+ owner, _, project_name, run_uuid = get_project_run_or_local(
1311
1317
  project or ctx.obj.get("project"),
1312
1318
  uid or ctx.obj.get("run_uuid"),
1313
1319
  is_cli=True,
@@ -1375,7 +1381,7 @@ def statuses(ctx, project, uid, watch, offline, path):
1375
1381
  # )
1376
1382
  # sys.exit(1)
1377
1383
  #
1378
- # owner, project_name, run_uuid = get_project_run_or_local(
1384
+ # owner, team, project_name, run_uuid = get_project_run_or_local(
1379
1385
  # ctx.obj.get("project"), ctx.obj.get("run_uuid"), is_cli=True,
1380
1386
  # )
1381
1387
  #
@@ -1467,7 +1473,7 @@ def logs(ctx, project, uid, follow, hide_time, all_containers, all_info, offline
1467
1473
  sys.exit(1)
1468
1474
  return
1469
1475
 
1470
- owner, project_name, run_uuid = get_project_run_or_local(
1476
+ owner, _, project_name, run_uuid = get_project_run_or_local(
1471
1477
  project or ctx.obj.get("project"),
1472
1478
  uid or ctx.obj.get("run_uuid"),
1473
1479
  is_cli=True,
@@ -1513,7 +1519,7 @@ def inspect(ctx, project, uid):
1513
1519
  \b
1514
1520
  $ polyaxon ops inspect -p acme/project -uid 8aac02e3a62a4f0aaa257c59da5eab80
1515
1521
  """
1516
- owner, project_name, run_uuid = get_project_run_or_local(
1522
+ owner, _, project_name, run_uuid = get_project_run_or_local(
1517
1523
  project or ctx.obj.get("project"),
1518
1524
  uid or ctx.obj.get("run_uuid"),
1519
1525
  is_cli=True,
@@ -1572,7 +1578,7 @@ def shell(ctx, project, uid, command, pod, container):
1572
1578
  """
1573
1579
  from polyaxon._vendor.shell_pty import PseudoTerminal
1574
1580
 
1575
- owner, project_name, run_uuid = get_project_run_or_local(
1581
+ owner, _, project_name, run_uuid = get_project_run_or_local(
1576
1582
  project or ctx.obj.get("project"),
1577
1583
  uid or ctx.obj.get("run_uuid"),
1578
1584
  is_cli=True,
@@ -1677,7 +1683,7 @@ def artifacts(
1677
1683
  \b
1678
1684
  $ polyaxon ops artifacts -uid 8aac02e3a62a4f0aaa257c59da5eab80 -l-kind model -l-kind env --path="this/path"
1679
1685
  """
1680
- owner, project_name, run_uuid = get_project_run_or_local(
1686
+ owner, _, project_name, run_uuid = get_project_run_or_local(
1681
1687
  project or ctx.obj.get("project"),
1682
1688
  uid or ctx.obj.get("run_uuid"),
1683
1689
  is_cli=True,
@@ -1855,7 +1861,7 @@ def upload(ctx, project, uid, path_from, path_to, sync_failure):
1855
1861
  \b
1856
1862
  $ polyaxon ops upload -uid 8aac02e3a62a4f0aaa257c59da5eab80 --path-to="path/to/upload/to"
1857
1863
  """
1858
- owner, project_name, run_uuid = get_project_run_or_local(
1864
+ owner, _, project_name, run_uuid = get_project_run_or_local(
1859
1865
  project or ctx.obj.get("project"),
1860
1866
  uid or ctx.obj.get("run_uuid"),
1861
1867
  is_cli=True,
@@ -1929,7 +1935,7 @@ def transfer(ctx, project, uid, to_project):
1929
1935
  \b
1930
1936
  $ polyaxon ops transfer -p acme/foobar -uid 8aac02e3a62a4f0aaa257c59da5eab80 -to=dest-project
1931
1937
  """
1932
- owner, project_name, run_uuid = get_project_run_or_local(
1938
+ owner, _, project_name, run_uuid = get_project_run_or_local(
1933
1939
  project or ctx.obj.get("project"),
1934
1940
  uid or ctx.obj.get("run_uuid"),
1935
1941
  is_cli=True,
@@ -1997,13 +2003,16 @@ def dashboard(ctx, project, uid, yes, url, offline, path, server_config):
1997
2003
  sys.exit(1)
1998
2004
  run_data = RunConfigManager.read_from_path(offline_path)
1999
2005
  owner, project_name, run_uuid = run_data.owner, run_data.project, run_data.uuid
2006
+ team = None
2000
2007
  else:
2001
- owner, project_name, run_uuid = get_project_run_or_local(
2008
+ owner, team, project_name, run_uuid = get_project_run_or_local(
2002
2009
  project or ctx.obj.get("project"),
2003
2010
  uid or ctx.obj.get("run_uuid"),
2004
2011
  is_cli=True,
2005
2012
  )
2006
- subpath = "{}/{}/runs/{}".format(owner, project_name, run_uuid)
2013
+ subpath = "{}/runs/{}".format(
2014
+ get_project_subpath_url(owner, team, project_name), run_uuid
2015
+ )
2007
2016
  dashboard_url = get_dashboard_url(subpath=subpath)
2008
2017
  get_dashboard(dashboard_url=dashboard_url, url_only=url, yes=yes)
2009
2018
  if offline:
@@ -2047,7 +2056,7 @@ def service(ctx, project, uid, yes, external, url):
2047
2056
  You can open the service embedded in Polyaxon UI or using the real service URL,
2048
2057
  please use the `--external` flag.
2049
2058
  """
2050
- owner, project_name, run_uuid = get_project_run_or_local(
2059
+ owner, team, project_name, run_uuid = get_project_run_or_local(
2051
2060
  project or ctx.obj.get("project"),
2052
2061
  uid or ctx.obj.get("run_uuid"),
2053
2062
  is_cli=True,
@@ -2081,7 +2090,9 @@ def service(ctx, project, uid, yes, external, url):
2081
2090
  wait_for_running_condition(client)
2082
2091
 
2083
2092
  run_url = get_dashboard_url(
2084
- subpath="{}/{}/runs/{}/service".format(owner, project_name, run_uuid)
2093
+ subpath="{}/runs/{}/service".format(
2094
+ get_project_subpath_url(owner, team, project_name), run_uuid
2095
+ )
2085
2096
  )
2086
2097
 
2087
2098
  namespace = client.run_data.settings.namespace
@@ -2091,8 +2102,8 @@ def service(ctx, project, uid, yes, external, url):
2091
2102
  if rewrite_path:
2092
2103
  service_endpoint = REWRITE_EXTERNAL_V1 if is_external else REWRITE_SERVICES_V1
2093
2104
 
2094
- service_subpath = "{}/{}/{}/runs/{}/".format(
2095
- namespace, owner, project_name, run_uuid
2105
+ service_subpath = "{}/{}/runs/{}/".format(
2106
+ get_project_subpath_url(namespace, team, owner), project_name, run_uuid
2096
2107
  )
2097
2108
  port = 80
2098
2109
  if client.settings and client.settings.agent:
@@ -2188,7 +2199,7 @@ def pull(
2188
2199
  \b
2189
2200
  $ polyaxon ops pull -a
2190
2201
  """
2191
- owner, project_name = get_project_or_local(
2202
+ owner, _, project_name = get_project_or_local(
2192
2203
  project or ctx.obj.get("project"), is_cli=True
2193
2204
  )
2194
2205
 
@@ -2308,7 +2319,7 @@ def push(ctx, project, uid, all_runs, no_artifacts, clean, path, reset_project):
2308
2319
  \b
2309
2320
  $ polyaxon ops push -uid 8aac02e3a62a4f0aaa257c59da5eab80 --reset-project -p send-to-project
2310
2321
  """
2311
- owner, project_name = get_project_or_local(
2322
+ owner, _, project_name = get_project_or_local(
2312
2323
  project or ctx.obj.get("project"), is_cli=True
2313
2324
  )
2314
2325
 
@@ -12,7 +12,7 @@ from clipped.utils.responses import get_meta_response
12
12
  from clipped.utils.validation import validate_tags
13
13
  from urllib3.exceptions import HTTPError
14
14
 
15
- from polyaxon._cli.dashboard import get_dashboard_url
15
+ from polyaxon._cli.dashboard import get_dashboard_url, get_project_subpath_url
16
16
  from polyaxon._cli.errors import handle_cli_error
17
17
  from polyaxon._contexts.paths import get_offline_base_path
18
18
  from polyaxon._schemas.lifecycle import V1ProjectVersionKind
@@ -170,6 +170,7 @@ def list_project_versions(
170
170
 
171
171
  def register_project_version(
172
172
  owner: str,
173
+ team: Optional[str],
173
174
  project_name: str,
174
175
  version: str,
175
176
  kind: V1ProjectVersionKind,
@@ -209,7 +210,9 @@ def register_project_version(
209
210
  Printer.print(
210
211
  "You can view this version on Polyaxon UI: {}".format(
211
212
  get_dashboard_url(
212
- subpath="{}/{}/{}s/{}".format(owner, project_name, kind, version)
213
+ subpath="{}/{}s/{}".format(
214
+ get_project_subpath_url(owner, team, project_name), kind, version
215
+ )
213
216
  )
214
217
  )
215
218
  )
@@ -217,6 +220,7 @@ def register_project_version(
217
220
 
218
221
  def copy_project_version(
219
222
  owner: str,
223
+ team: Optional[str],
220
224
  project_name: str,
221
225
  version: str,
222
226
  kind: V1ProjectVersionKind,
@@ -261,8 +265,10 @@ def copy_project_version(
261
265
  Printer.print(
262
266
  "You can view this version on Polyaxon UI: {}".format(
263
267
  get_dashboard_url(
264
- subpath="{}/{}/{}s/{}".format(
265
- owner, to_project or project_name, kind, _version.name
268
+ subpath="{}/{}s/{}".format(
269
+ get_project_subpath_url(owner, team, to_project or project_name),
270
+ kind,
271
+ _version.name,
266
272
  )
267
273
  )
268
274
  )
@@ -271,6 +277,7 @@ def copy_project_version(
271
277
 
272
278
  def get_project_version(
273
279
  owner: str,
280
+ team: Optional[str],
274
281
  project_name: str,
275
282
  kind: V1ProjectVersionKind,
276
283
  version: str,
@@ -288,6 +295,17 @@ def get_project_version(
288
295
  try:
289
296
  response = polyaxon_client.get_version(kind, version)
290
297
  get_version_details(response, content_callback)
298
+ Printer.print(
299
+ "You can view this version on Polyaxon UI: {}".format(
300
+ get_dashboard_url(
301
+ subpath="{}/{}s/{}".format(
302
+ get_project_subpath_url(owner, team, project_name),
303
+ kind,
304
+ version,
305
+ )
306
+ )
307
+ )
308
+ )
291
309
  except (ApiException, HTTPError) as e:
292
310
  handle_cli_error(
293
311
  e,
@@ -470,13 +488,16 @@ def stage_project_version(
470
488
 
471
489
  def open_project_version_dashboard(
472
490
  owner: str,
491
+ team: Optional[str],
473
492
  project_name: str,
474
493
  kind: V1ProjectVersionKind,
475
494
  version: str,
476
495
  url: str,
477
496
  yes: bool = False,
478
497
  ):
479
- subpath = "{}/{}/{}s/{}".format(owner, project_name, kind, version)
498
+ subpath = "{}/{}s/{}".format(
499
+ get_project_subpath_url(owner, team, project_name), kind, version
500
+ )
480
501
 
481
502
  artifact_url = get_dashboard_url(subpath=subpath)
482
503
  if url:
polyaxon/_cli/projects.py CHANGED
@@ -8,7 +8,7 @@ from clipped.utils.responses import get_meta_response
8
8
  from clipped.utils.validation import validate_tags
9
9
  from urllib3.exceptions import HTTPError
10
10
 
11
- from polyaxon._cli.dashboard import get_dashboard_url
11
+ from polyaxon._cli.dashboard import get_dashboard_url, get_project_subpath_url
12
12
  from polyaxon._cli.errors import handle_cli_error
13
13
  from polyaxon._cli.init import init as init_project
14
14
  from polyaxon._cli.options import OPTIONS_NAME, OPTIONS_OWNER, OPTIONS_PROJECT
@@ -19,6 +19,7 @@ from polyaxon._env_vars.getters.user import get_local_owner
19
19
  from polyaxon._managers.project import ProjectConfigManager
20
20
  from polyaxon._utils import cache
21
21
  from polyaxon._utils.cache import get_local_project
22
+ from polyaxon._utils.fqn_utils import get_owner_team_space
22
23
  from polyaxon.client import ProjectClient, V1Project
23
24
  from polyaxon.exceptions import ApiException
24
25
  from polyaxon.logger import clean_outputs
@@ -74,7 +75,7 @@ def create(ctx, name, description, tags, public, init):
74
75
  command_help="project create",
75
76
  sys_exit=True,
76
77
  )
77
- owner, project_name = resolve_entity_info(
78
+ owner, team, project_name = resolve_entity_info(
78
79
  name or ctx.obj.get("project"), is_cli=True, entity_name="project"
79
80
  )
80
81
 
@@ -90,7 +91,9 @@ def create(ctx, name, description, tags, public, init):
90
91
  project_config = V1Project(
91
92
  name=project_name, description=description, tags=tags, is_public=public
92
93
  )
93
- polyaxon_client = ProjectClient(owner=owner, manual_exceptions_handling=True)
94
+ polyaxon_client = ProjectClient(
95
+ owner=get_owner_team_space(owner, team), manual_exceptions_handling=True
96
+ )
94
97
  _project = polyaxon_client.create(project_config)
95
98
  config = polyaxon_client.client.sanitize_for_serialization(_project)
96
99
  cache.cache(config_manager=ProjectConfigManager, config=config)
@@ -103,7 +106,9 @@ def create(ctx, name, description, tags, public, init):
103
106
  Printer.success("Project `{}` was created successfully.".format(_project.name))
104
107
  Printer.print(
105
108
  "You can view this project on Polyaxon UI: {}".format(
106
- get_dashboard_url(subpath="{}/{}".format(owner, _project.name))
109
+ get_dashboard_url(
110
+ subpath=get_project_subpath_url(owner, team, _project.name)
111
+ )
107
112
  )
108
113
  )
109
114
 
@@ -195,7 +200,7 @@ def get(ctx, _project):
195
200
  \b
196
201
  $ polyaxon project get -p owner/project
197
202
  """
198
- owner, project_name = get_project_or_local(
203
+ owner, team, project_name = get_project_or_local(
199
204
  _project or ctx.obj.get("project"), is_cli=True
200
205
  )
201
206
 
@@ -214,6 +219,13 @@ def get(ctx, _project):
214
219
  project=project_name,
215
220
  )
216
221
  get_entity_details(polyaxon_client.project_data, "Project")
222
+ Printer.print(
223
+ "You can view this project on Polyaxon UI: {}".format(
224
+ get_dashboard_url(
225
+ subpath=get_project_subpath_url(owner, team, project_name)
226
+ )
227
+ )
228
+ )
217
229
  except (ApiException, HTTPError) as e:
218
230
  handle_cli_error(
219
231
  e, message="Could not get project `{}`.".format(project_name), sys_exit=True
@@ -237,7 +249,7 @@ def delete(ctx, _project, yes):
237
249
 
238
250
  Uses /docs/core/cli/#caching
239
251
  """
240
- owner, project_name = get_project_or_local(
252
+ owner, _, project_name = get_project_or_local(
241
253
  _project or ctx.obj.get("project"), is_cli=True
242
254
  )
243
255
 
@@ -300,7 +312,7 @@ def update(ctx, _project, name, description, tags, private):
300
312
  \b
301
313
  $ polyaxon update --tags="foo, bar"
302
314
  """
303
- owner, project_name = get_project_or_local(
315
+ owner, _, project_name = get_project_or_local(
304
316
  _project or ctx.obj.get("project"), is_cli=True
305
317
  )
306
318
 
@@ -357,10 +369,12 @@ def update(ctx, _project, name, description, tags, private):
357
369
  @clean_outputs
358
370
  def dashboard(ctx, _project, yes, url):
359
371
  """Open this project's dashboard details in browser."""
360
- owner, project_name = get_project_or_local(
372
+ owner, team, project_name = get_project_or_local(
361
373
  _project or ctx.obj.get("project"), is_cli=True
362
374
  )
363
- project_url = get_dashboard_url(subpath="{}/{}".format(owner, project_name))
375
+ project_url = get_dashboard_url(
376
+ subpath=get_project_subpath_url(owner, team, project_name)
377
+ )
364
378
  if url:
365
379
  Printer.header("The dashboard is available at: {}".format(project_url))
366
380
  sys.exit(0)
polyaxon/_cli/run.py CHANGED
@@ -10,7 +10,7 @@ from clipped.utils import git as git_utils
10
10
  from clipped.utils.validation import validate_tags
11
11
  from urllib3.exceptions import HTTPError
12
12
 
13
- from polyaxon._cli.dashboard import get_dashboard_url
13
+ from polyaxon._cli.dashboard import get_dashboard_url, get_project_subpath_url
14
14
  from polyaxon._cli.errors import handle_cli_error
15
15
  from polyaxon._cli.operations import approve
16
16
  from polyaxon._cli.operations import execute as run_execute
@@ -30,6 +30,7 @@ from polyaxon._polyaxonfile import check_polyaxonfile
30
30
  from polyaxon._runner.kinds import RunnerKind
31
31
  from polyaxon._schemas.lifecycle import ManagedBy
32
32
  from polyaxon._utils import cache
33
+ from polyaxon._utils.fqn_utils import get_owner_team_space
33
34
  from polyaxon.client import RunClient
34
35
  from polyaxon.exceptions import ApiException
35
36
  from polyaxon.logger import clean_outputs
@@ -43,6 +44,7 @@ def _run(
43
44
  ctx,
44
45
  name: str,
45
46
  owner: str,
47
+ team: Optional[str],
46
48
  project_name: str,
47
49
  description: str,
48
50
  tags: List[str],
@@ -61,11 +63,14 @@ def _run(
61
63
  owner=owner, project=project_name, manual_exceptions_handling=True
62
64
  )
63
65
 
66
+ owner_team = get_owner_team_space(owner, team)
67
+ project_url = get_project_subpath_url(owner, team, project_name)
68
+
64
69
  def get_instance_info(r):
65
70
  rn = (
66
71
  f"[white]{r.name}[/white]@[white]{r.uuid}[/white]"
67
72
  if r.name
68
- else "[white]{r.uuid}[/white]"
73
+ else f"[white]{r.uuid}[/white]"
69
74
  )
70
75
  return f"[white]{owner}[/white]/[white]{project_name}[/white]:{rn}"
71
76
 
@@ -93,8 +98,15 @@ def _run(
93
98
  meta_info=meta_info,
94
99
  pending=pending,
95
100
  )
101
+ host_kwargs = {}
102
+ if (
103
+ response.settings
104
+ and response.settings.agent
105
+ and response.settings.agent.host
106
+ ):
107
+ host_kwargs["host"] = response.settings.agent.host
96
108
  run_url = get_dashboard_url(
97
- subpath="{}/{}/runs/{}".format(owner, project_name, response.uuid)
109
+ subpath="{}/runs/{}".format(project_url, response.uuid), **host_kwargs
98
110
  )
99
111
  if output:
100
112
  response_data = polyaxon_client.client.sanitize_for_serialization(
@@ -125,26 +137,38 @@ def _run(
125
137
 
126
138
  def execute_run_locally(run_uuid: str):
127
139
  ctx.obj = {
128
- "project": "{}/{}".format(owner, project_name),
140
+ "project": "{}/{}".format(owner_team, project_name),
129
141
  "run_uuid": run_uuid,
130
142
  "executor": executor,
131
143
  }
132
144
  ctx.invoke(run_execute)
133
145
 
134
146
  def watch_run_statuses(run_uuid: str):
135
- ctx.obj = {"project": "{}/{}".format(owner, project_name), "run_uuid": run_uuid}
147
+ ctx.obj = {
148
+ "project": "{}/{}".format(owner_team, project_name),
149
+ "run_uuid": run_uuid,
150
+ }
136
151
  ctx.invoke(statuses, watch=True)
137
152
 
138
153
  def watch_run_logs(run_uuid: str):
139
- ctx.obj = {"project": "{}/{}".format(owner, project_name), "run_uuid": run_uuid}
154
+ ctx.obj = {
155
+ "project": "{}/{}".format(owner_team, project_name),
156
+ "run_uuid": run_uuid,
157
+ }
140
158
  ctx.invoke(run_logs)
141
159
 
142
160
  def start_run_shell(run_uuid: str):
143
- ctx.obj = {"project": "{}/{}".format(owner, project_name), "run_uuid": run_uuid}
161
+ ctx.obj = {
162
+ "project": "{}/{}".format(owner_team, project_name),
163
+ "run_uuid": run_uuid,
164
+ }
144
165
  ctx.invoke(run_shell)
145
166
 
146
167
  def upload_run(run_uuid: str):
147
- ctx.obj = {"project": "{}/{}".format(owner, project_name), "run_uuid": run_uuid}
168
+ ctx.obj = {
169
+ "project": "{}/{}".format(owner_team, project_name),
170
+ "run_uuid": run_uuid,
171
+ }
148
172
  ctx.invoke(
149
173
  run_upload, path_to=upload_to, path_from=upload_from, sync_failure=True
150
174
  )
@@ -555,13 +579,14 @@ def run(
555
579
  Printer.print("Please customize the specification or disable the template!")
556
580
  sys.exit(1)
557
581
 
558
- owner, project_name = get_project_or_local(project, is_cli=True)
582
+ owner, team, project_name = get_project_or_local(project, is_cli=True)
559
583
  tags = validate_tags(tags, validate_yaml=True)
560
584
 
561
585
  _run(
562
586
  ctx=ctx,
563
587
  name=name,
564
588
  owner=owner,
589
+ team=team,
565
590
  project_name=project_name,
566
591
  description=description,
567
592
  tags=tags,
@@ -0,0 +1,39 @@
1
+ from polyaxon import settings
2
+ from polyaxon._client.client import PolyaxonClient
3
+ from polyaxon._schemas.client import ClientConfig
4
+ from polyaxon._utils.fqn_utils import split_owner_team_space
5
+
6
+
7
+ class ClientMixin:
8
+ @property
9
+ def client(self):
10
+ if self._client:
11
+ return self._client
12
+ self._client = PolyaxonClient()
13
+ return self._client
14
+
15
+ def reset_client(self, **kwargs):
16
+ if not settings.CLIENT_CONFIG.in_cluster:
17
+ self._client = PolyaxonClient(
18
+ ClientConfig.patch_from(settings.CLIENT_CONFIG, **kwargs)
19
+ )
20
+
21
+ @property
22
+ def owner(self) -> str:
23
+ return self._owner
24
+
25
+ @property
26
+ def team(self):
27
+ return self._team
28
+
29
+ @property
30
+ def project(self) -> str:
31
+ return self._project
32
+
33
+ def set_project(self, project: str):
34
+ self._project = project
35
+
36
+ def set_owner(self, owner: str):
37
+ owner, team = split_owner_team_space(owner)
38
+ self._owner = owner
39
+ self._team = team
@@ -12,6 +12,7 @@ from clipped.utils.validation import validate_tags
12
12
 
13
13
  from polyaxon._client.client import PolyaxonClient
14
14
  from polyaxon._client.decorators import client_handler, get_global_or_inline_config
15
+ from polyaxon._client.mixin import ClientMixin
15
16
  from polyaxon._constants.globals import DEFAULT
16
17
  from polyaxon._contexts import paths as ctx_paths
17
18
  from polyaxon._env_vars.getters.user import get_local_owner
@@ -21,13 +22,17 @@ from polyaxon._sdk.schemas.v1_list_project_versions_response import (
21
22
  )
22
23
  from polyaxon._sdk.schemas.v1_project import V1Project
23
24
  from polyaxon._sdk.schemas.v1_project_version import V1ProjectVersion
24
- from polyaxon._utils.fqn_utils import get_entity_full_name, get_entity_info
25
+ from polyaxon._utils.fqn_utils import (
26
+ get_entity_full_name,
27
+ get_entity_info,
28
+ split_owner_team_space,
29
+ )
25
30
  from polyaxon.exceptions import ApiException, PolyaxonClientException
26
31
  from polyaxon.logger import logger
27
32
  from traceml.artifacts import V1RunArtifact
28
33
 
29
34
 
30
- class ProjectClient:
35
+ class ProjectClient(ClientMixin):
31
36
  """ProjectClient is a client to communicate with Polyaxon projects endpoints.
32
37
 
33
38
  If no values are passed to this class,
@@ -94,26 +99,13 @@ class ProjectClient:
94
99
  if not owner:
95
100
  raise PolyaxonClientException("Please provide a valid owner.")
96
101
 
102
+ owner, team = split_owner_team_space(owner)
97
103
  self._client = client
98
104
  self._owner = owner or DEFAULT
105
+ self._team = team
99
106
  self._project = project
100
107
  self._project_data = V1Project.construct()
101
108
 
102
- @property
103
- def client(self):
104
- if self._client:
105
- return self._client
106
- self._client = PolyaxonClient()
107
- return self._client
108
-
109
- @property
110
- def owner(self):
111
- return self._owner
112
-
113
- @property
114
- def project(self):
115
- return self._project
116
-
117
109
  @property
118
110
  def project_data(self):
119
111
  return self._project_data
@@ -139,11 +131,19 @@ class ProjectClient:
139
131
  Returns:
140
132
  V1Project, project instance from the response.
141
133
  """
142
- self._project_data = self.client.projects_v1.create_project(
143
- self.owner,
144
- data,
145
- async_req=False,
146
- )
134
+ if self.team:
135
+ self._project_data = self.client.projects_v1.create_team_project(
136
+ self.owner,
137
+ self.team,
138
+ data,
139
+ async_req=False,
140
+ )
141
+ else:
142
+ self._project_data = self.client.projects_v1.create_project(
143
+ self.owner,
144
+ data,
145
+ async_req=False,
146
+ )
147
147
  self._project_data.owner = self.owner
148
148
  self._project = self._project_data.name
149
149
  return self._project_data