polyaxon 2.1.0rc9__py3-none-any.whl → 2.6.0__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.
Files changed (270) hide show
  1. polyaxon/_auxiliaries/default_scheduling.py +17 -7
  2. polyaxon/_auxiliaries/init.py +14 -6
  3. polyaxon/_auxiliaries/sidecar.py +10 -8
  4. polyaxon/_cli/artifacts.py +96 -11
  5. polyaxon/_cli/components.py +96 -11
  6. polyaxon/_cli/config.py +31 -0
  7. polyaxon/_cli/dashboard.py +12 -2
  8. polyaxon/_cli/init.py +1 -1
  9. polyaxon/_cli/models.py +96 -11
  10. polyaxon/_cli/operations.py +133 -58
  11. polyaxon/_cli/project_versions.py +139 -6
  12. polyaxon/_cli/projects.py +23 -9
  13. polyaxon/_cli/run.py +43 -9
  14. polyaxon/_cli/services/agent.py +2 -2
  15. polyaxon/_cli/version.py +4 -1
  16. polyaxon/_client/mixin.py +39 -0
  17. polyaxon/_client/project.py +218 -23
  18. polyaxon/_client/run.py +84 -27
  19. polyaxon/_compiler/contexts/contexts.py +4 -0
  20. polyaxon/_compiler/contexts/ray_job.py +4 -2
  21. polyaxon/_compiler/resolver/agent.py +22 -10
  22. polyaxon/_compiler/resolver/runtime.py +7 -3
  23. polyaxon/_constants/metadata.py +1 -0
  24. polyaxon/_contexts/keys.py +1 -0
  25. polyaxon/_contexts/paths.py +1 -1
  26. polyaxon/_deploy/operators/compose.py +1 -27
  27. polyaxon/_deploy/schemas/auth.py +3 -3
  28. polyaxon/_deploy/schemas/celery.py +10 -8
  29. polyaxon/_deploy/schemas/deployment.py +148 -115
  30. polyaxon/_deploy/schemas/email.py +8 -8
  31. polyaxon/_deploy/schemas/ingress.py +7 -7
  32. polyaxon/_deploy/schemas/intervals.py +2 -7
  33. polyaxon/_deploy/schemas/operators.py +8 -8
  34. polyaxon/_deploy/schemas/proxy.py +9 -8
  35. polyaxon/_deploy/schemas/rbac.py +1 -1
  36. polyaxon/_deploy/schemas/root_user.py +5 -5
  37. polyaxon/_deploy/schemas/security_context.py +25 -15
  38. polyaxon/_deploy/schemas/service.py +75 -66
  39. polyaxon/_deploy/schemas/ssl.py +3 -3
  40. polyaxon/_deploy/schemas/ui.py +10 -6
  41. polyaxon/_docker/builder/builder.py +4 -1
  42. polyaxon/_docker/converter/base/containers.py +4 -7
  43. polyaxon/_docker/converter/base/env_vars.py +5 -5
  44. polyaxon/_docker/converter/base/mounts.py +2 -2
  45. polyaxon/_docker/docker_types.py +57 -30
  46. polyaxon/_env_vars/getters/owner_entity.py +4 -2
  47. polyaxon/_env_vars/getters/project.py +4 -2
  48. polyaxon/_env_vars/getters/run.py +5 -2
  49. polyaxon/_env_vars/keys.py +3 -0
  50. polyaxon/_flow/__init__.py +3 -2
  51. polyaxon/_flow/builds/__init__.py +8 -8
  52. polyaxon/_flow/cache/__init__.py +4 -4
  53. polyaxon/_flow/component/base.py +25 -18
  54. polyaxon/_flow/component/component.py +4 -3
  55. polyaxon/_flow/early_stopping/__init__.py +1 -1
  56. polyaxon/_flow/early_stopping/policies.py +12 -10
  57. polyaxon/_flow/environment/__init__.py +43 -25
  58. polyaxon/_flow/events/__init__.py +1 -1
  59. polyaxon/_flow/hooks/__init__.py +11 -11
  60. polyaxon/_flow/init/__init__.py +41 -25
  61. polyaxon/_flow/io/io.py +57 -47
  62. polyaxon/_flow/joins/__init__.py +5 -5
  63. polyaxon/_flow/matrix/bayes.py +23 -17
  64. polyaxon/_flow/matrix/grid_search.py +16 -7
  65. polyaxon/_flow/matrix/hyperband.py +10 -10
  66. polyaxon/_flow/matrix/hyperopt.py +14 -9
  67. polyaxon/_flow/matrix/iterative.py +14 -8
  68. polyaxon/_flow/matrix/mapping.py +4 -4
  69. polyaxon/_flow/matrix/params.py +138 -77
  70. polyaxon/_flow/matrix/random_search.py +10 -5
  71. polyaxon/_flow/matrix/tuner.py +4 -4
  72. polyaxon/_flow/mounts/artifacts_mounts.py +1 -1
  73. polyaxon/_flow/notifications/__init__.py +1 -1
  74. polyaxon/_flow/operations/base.py +10 -8
  75. polyaxon/_flow/operations/compiled_operation.py +5 -4
  76. polyaxon/_flow/operations/operation.py +57 -41
  77. polyaxon/_flow/optimization/__init__.py +2 -2
  78. polyaxon/_flow/params/params.py +10 -9
  79. polyaxon/_flow/plugins/__init__.py +19 -13
  80. polyaxon/_flow/run/dag.py +12 -9
  81. polyaxon/_flow/run/dask/dask.py +4 -4
  82. polyaxon/_flow/run/dask/replica.py +17 -11
  83. polyaxon/_flow/run/job.py +17 -11
  84. polyaxon/_flow/run/kubeflow/mpi_job.py +10 -5
  85. polyaxon/_flow/run/kubeflow/mx_job.py +25 -9
  86. polyaxon/_flow/run/kubeflow/paddle_job.py +16 -9
  87. polyaxon/_flow/run/kubeflow/pytorch_job.py +24 -17
  88. polyaxon/_flow/run/kubeflow/replica.py +17 -11
  89. polyaxon/_flow/run/kubeflow/scheduling_policy.py +7 -5
  90. polyaxon/_flow/run/kubeflow/tf_job.py +15 -8
  91. polyaxon/_flow/run/kubeflow/xgboost_job.py +9 -4
  92. polyaxon/_flow/run/ray/ray.py +9 -6
  93. polyaxon/_flow/run/ray/replica.py +25 -16
  94. polyaxon/_flow/run/resources.py +14 -13
  95. polyaxon/_flow/run/service.py +4 -4
  96. polyaxon/_flow/schedules/cron.py +4 -4
  97. polyaxon/_flow/schedules/interval.py +4 -4
  98. polyaxon/_flow/templates/__init__.py +3 -3
  99. polyaxon/_flow/termination/__init__.py +3 -3
  100. polyaxon/_fs/async_manager.py +1 -1
  101. polyaxon/_fs/fs.py +1 -1
  102. polyaxon/_fs/watcher.py +26 -27
  103. polyaxon/_k8s/converter/base/base.py +2 -1
  104. polyaxon/_k8s/converter/base/main.py +1 -0
  105. polyaxon/_k8s/converter/common/accelerators.py +7 -4
  106. polyaxon/_k8s/converter/converters/ray_job.py +4 -2
  107. polyaxon/_k8s/custom_resources/dask_job.py +3 -0
  108. polyaxon/_k8s/custom_resources/kubeflow/common.py +4 -1
  109. polyaxon/_k8s/custom_resources/ray_job.py +3 -0
  110. polyaxon/_k8s/custom_resources/setter.py +1 -1
  111. polyaxon/_k8s/executor/async_executor.py +2 -0
  112. polyaxon/_k8s/k8s_validation.py +1 -1
  113. polyaxon/_k8s/logging/async_monitor.py +82 -11
  114. polyaxon/_k8s/manager/async_manager.py +15 -0
  115. polyaxon/_k8s/manager/manager.py +16 -1
  116. polyaxon/_local_process/__init__.py +0 -0
  117. polyaxon/_local_process/agent.py +6 -0
  118. polyaxon/_local_process/converter/__init__.py +1 -0
  119. polyaxon/_local_process/converter/base/__init__.py +1 -0
  120. polyaxon/_local_process/converter/base/base.py +140 -0
  121. polyaxon/_local_process/converter/base/containers.py +66 -0
  122. polyaxon/_local_process/converter/base/env_vars.py +253 -0
  123. polyaxon/_local_process/converter/base/init.py +414 -0
  124. polyaxon/_local_process/converter/base/main.py +74 -0
  125. polyaxon/_local_process/converter/base/mounts.py +82 -0
  126. polyaxon/_local_process/converter/converters/__init__.py +8 -0
  127. polyaxon/_local_process/converter/converters/job.py +40 -0
  128. polyaxon/_local_process/converter/converters/service.py +41 -0
  129. polyaxon/_local_process/converter/mixins.py +38 -0
  130. polyaxon/_local_process/executor.py +132 -0
  131. polyaxon/_local_process/process_types.py +42 -0
  132. polyaxon/_polyaxonfile/specs/compiled_operation.py +1 -1
  133. polyaxon/_polyaxonfile/specs/libs/parser.py +1 -1
  134. polyaxon/_polyaxonfile/specs/libs/validator.py +1 -1
  135. polyaxon/_polyaxonfile/specs/operation.py +1 -1
  136. polyaxon/_polyaxonfile/specs/sections.py +8 -0
  137. polyaxon/_pql/manager.py +1 -1
  138. polyaxon/_runner/agent/async_agent.py +25 -11
  139. polyaxon/_runner/agent/base_agent.py +19 -10
  140. polyaxon/_runner/agent/sync_agent.py +24 -10
  141. polyaxon/_runner/converter/converter.py +12 -4
  142. polyaxon/_runner/executor.py +1 -1
  143. polyaxon/_schemas/agent.py +69 -37
  144. polyaxon/_schemas/authentication.py +4 -4
  145. polyaxon/_schemas/base.py +26 -2
  146. polyaxon/_schemas/checks.py +3 -3
  147. polyaxon/_schemas/cli.py +4 -6
  148. polyaxon/_schemas/client.py +20 -18
  149. polyaxon/_schemas/compatibility.py +4 -4
  150. polyaxon/_schemas/container_resources.py +1 -1
  151. polyaxon/_schemas/home.py +3 -3
  152. polyaxon/_schemas/installation.py +13 -9
  153. polyaxon/_schemas/lifecycle.py +23 -23
  154. polyaxon/_schemas/log_handler.py +2 -2
  155. polyaxon/_schemas/services.py +26 -14
  156. polyaxon/_schemas/types/artifacts.py +3 -3
  157. polyaxon/_schemas/types/dockerfile.py +14 -12
  158. polyaxon/_schemas/types/event.py +2 -2
  159. polyaxon/_schemas/types/file.py +3 -3
  160. polyaxon/_schemas/types/git.py +12 -4
  161. polyaxon/_schemas/types/tensorboard.py +14 -8
  162. polyaxon/_schemas/user.py +3 -3
  163. polyaxon/_schemas/version.py +2 -2
  164. polyaxon/_sdk/api/agents_v1_api.py +222 -43
  165. polyaxon/_sdk/api/artifacts_stores_v1_api.py +3 -3
  166. polyaxon/_sdk/api/auth_v1_api.py +13 -13
  167. polyaxon/_sdk/api/connections_v1_api.py +15 -15
  168. polyaxon/_sdk/api/dashboards_v1_api.py +15 -15
  169. polyaxon/_sdk/api/organizations_v1_api.py +85 -85
  170. polyaxon/_sdk/api/presets_v1_api.py +15 -15
  171. polyaxon/_sdk/api/project_dashboards_v1_api.py +29 -29
  172. polyaxon/_sdk/api/project_searches_v1_api.py +29 -29
  173. polyaxon/_sdk/api/projects_v1_api.py +284 -107
  174. polyaxon/_sdk/api/queues_v1_api.py +19 -19
  175. polyaxon/_sdk/api/runs_v1_api.py +313 -359
  176. polyaxon/_sdk/api/searches_v1_api.py +15 -15
  177. polyaxon/_sdk/api/service_accounts_v1_api.py +31 -31
  178. polyaxon/_sdk/api/tags_v1_api.py +17 -17
  179. polyaxon/_sdk/api/teams_v1_api.py +2854 -402
  180. polyaxon/_sdk/api/users_v1_api.py +254 -78
  181. polyaxon/_sdk/api/versions_v1_api.py +7 -7
  182. polyaxon/_sdk/async_client/api_client.py +4 -0
  183. polyaxon/_sdk/schemas/__init__.py +1 -1
  184. polyaxon/_sdk/schemas/v1_activity.py +8 -8
  185. polyaxon/_sdk/schemas/v1_agent.py +18 -16
  186. polyaxon/_sdk/schemas/v1_agent_state_response.py +4 -4
  187. polyaxon/_sdk/schemas/v1_agent_state_response_agent_state.py +10 -10
  188. polyaxon/_sdk/schemas/v1_agent_status_body_request.py +3 -3
  189. polyaxon/_sdk/schemas/v1_analytics_spec.py +4 -4
  190. polyaxon/_sdk/schemas/v1_artifact_tree.py +3 -3
  191. polyaxon/_sdk/schemas/v1_auth.py +1 -1
  192. polyaxon/_sdk/schemas/v1_cloning.py +3 -3
  193. polyaxon/_sdk/schemas/v1_connection_response.py +9 -9
  194. polyaxon/_sdk/schemas/v1_dashboard.py +9 -9
  195. polyaxon/_sdk/schemas/v1_dashboard_spec.py +5 -1
  196. polyaxon/_sdk/schemas/v1_entities_tags.py +2 -2
  197. polyaxon/_sdk/schemas/v1_entities_transfer.py +2 -2
  198. polyaxon/_sdk/schemas/v1_entity_notification_body.py +7 -7
  199. polyaxon/_sdk/schemas/v1_entity_stage_body_request.py +5 -5
  200. polyaxon/_sdk/schemas/v1_entity_status_body_request.py +5 -5
  201. polyaxon/_sdk/schemas/v1_events_response.py +2 -2
  202. polyaxon/_sdk/schemas/v1_list_activities_response.py +4 -4
  203. polyaxon/_sdk/schemas/v1_list_agents_response.py +4 -4
  204. polyaxon/_sdk/schemas/v1_list_bookmarks_response.py +4 -4
  205. polyaxon/_sdk/schemas/v1_list_connections_response.py +4 -4
  206. polyaxon/_sdk/schemas/v1_list_dashboards_response.py +4 -4
  207. polyaxon/_sdk/schemas/v1_list_organization_members_response.py +4 -4
  208. polyaxon/_sdk/schemas/v1_list_organizations_response.py +4 -4
  209. polyaxon/_sdk/schemas/v1_list_presets_response.py +4 -4
  210. polyaxon/_sdk/schemas/v1_list_project_versions_response.py +4 -4
  211. polyaxon/_sdk/schemas/v1_list_projects_response.py +4 -4
  212. polyaxon/_sdk/schemas/v1_list_queues_response.py +4 -4
  213. polyaxon/_sdk/schemas/v1_list_run_artifacts_response.py +4 -4
  214. polyaxon/_sdk/schemas/v1_list_run_connections_response.py +4 -4
  215. polyaxon/_sdk/schemas/v1_list_run_edges_response.py +4 -4
  216. polyaxon/_sdk/schemas/v1_list_runs_response.py +4 -4
  217. polyaxon/_sdk/schemas/v1_list_searches_response.py +4 -4
  218. polyaxon/_sdk/schemas/v1_list_service_accounts_response.py +4 -4
  219. polyaxon/_sdk/schemas/v1_list_tags_response.py +4 -4
  220. polyaxon/_sdk/schemas/v1_list_team_members_response.py +4 -4
  221. polyaxon/_sdk/schemas/v1_list_teams_response.py +4 -4
  222. polyaxon/_sdk/schemas/v1_list_token_response.py +4 -4
  223. polyaxon/_sdk/schemas/v1_operation_body.py +8 -8
  224. polyaxon/_sdk/schemas/v1_organization.py +16 -16
  225. polyaxon/_sdk/schemas/v1_organization_member.py +6 -6
  226. polyaxon/_sdk/schemas/v1_password_change.py +3 -3
  227. polyaxon/_sdk/schemas/v1_pipeline.py +3 -3
  228. polyaxon/_sdk/schemas/v1_preset.py +16 -9
  229. polyaxon/_sdk/schemas/v1_project.py +17 -17
  230. polyaxon/_sdk/schemas/v1_project_settings.py +12 -10
  231. polyaxon/_sdk/schemas/v1_project_version.py +20 -20
  232. polyaxon/_sdk/schemas/v1_queue.py +12 -12
  233. polyaxon/_sdk/schemas/v1_run.py +38 -38
  234. polyaxon/_sdk/schemas/v1_run_connection.py +3 -3
  235. polyaxon/_sdk/schemas/v1_run_edge.py +5 -5
  236. polyaxon/_sdk/schemas/v1_run_edge_lineage.py +3 -3
  237. polyaxon/_sdk/schemas/v1_run_edges_graph.py +1 -1
  238. polyaxon/_sdk/schemas/v1_run_reference_catalog.py +4 -4
  239. polyaxon/_sdk/schemas/v1_run_settings.py +9 -9
  240. polyaxon/_sdk/schemas/v1_search.py +10 -10
  241. polyaxon/_sdk/schemas/v1_search_spec.py +14 -14
  242. polyaxon/_sdk/schemas/v1_section_spec.py +12 -7
  243. polyaxon/_sdk/schemas/v1_service_account.py +9 -9
  244. polyaxon/_sdk/schemas/v1_settings_catalog.py +4 -3
  245. polyaxon/_sdk/schemas/v1_tag.py +6 -6
  246. polyaxon/_sdk/schemas/v1_team.py +11 -8
  247. polyaxon/_sdk/schemas/v1_team_member.py +6 -6
  248. polyaxon/_sdk/schemas/v1_team_settings.py +2 -2
  249. polyaxon/_sdk/schemas/v1_token.py +10 -10
  250. polyaxon/_sdk/schemas/v1_trial_start.py +6 -6
  251. polyaxon/_sdk/schemas/v1_user.py +6 -7
  252. polyaxon/_sdk/schemas/v1_user_access.py +17 -0
  253. polyaxon/_sdk/schemas/v1_user_email.py +1 -1
  254. polyaxon/_sdk/schemas/v1_user_singup.py +5 -5
  255. polyaxon/_sdk/schemas/v1_uuids.py +1 -1
  256. polyaxon/_sidecar/container/__init__.py +39 -20
  257. polyaxon/_sidecar/container/monitors/logs.py +10 -13
  258. polyaxon/_sidecar/ignore.py +0 -1
  259. polyaxon/_utils/cli_constants.py +2 -0
  260. polyaxon/_utils/fqn_utils.py +25 -2
  261. polyaxon/_utils/test_utils.py +2 -1
  262. polyaxon/pkg.py +1 -1
  263. polyaxon/schemas.py +1 -1
  264. {polyaxon-2.1.0rc9.dist-info → polyaxon-2.6.0.dist-info}/METADATA +43 -43
  265. {polyaxon-2.1.0rc9.dist-info → polyaxon-2.6.0.dist-info}/RECORD +269 -252
  266. {polyaxon-2.1.0rc9.dist-info → polyaxon-2.6.0.dist-info}/WHEEL +1 -1
  267. polyaxon/_sdk/schemas/v1_project_user_access.py +0 -10
  268. {polyaxon-2.1.0rc9.dist-info → polyaxon-2.6.0.dist-info}/LICENSE +0 -0
  269. {polyaxon-2.1.0rc9.dist-info → polyaxon-2.6.0.dist-info}/entry_points.txt +0 -0
  270. {polyaxon-2.1.0rc9.dist-info → polyaxon-2.6.0.dist-info}/top_level.txt +0 -0
@@ -1,3 +1,4 @@
1
+ import os
1
2
  import sys
2
3
 
3
4
  from typing import Callable, List, Optional, Union
@@ -11,8 +12,9 @@ from clipped.utils.responses import get_meta_response
11
12
  from clipped.utils.validation import validate_tags
12
13
  from urllib3.exceptions import HTTPError
13
14
 
14
- from polyaxon._cli.dashboard import get_dashboard_url
15
+ from polyaxon._cli.dashboard import get_dashboard_url, get_project_subpath_url
15
16
  from polyaxon._cli.errors import handle_cli_error
17
+ from polyaxon._contexts.paths import get_offline_base_path
16
18
  from polyaxon._schemas.lifecycle import V1ProjectVersionKind
17
19
  from polyaxon._utils.fqn_utils import get_versioned_entity_full_name
18
20
  from polyaxon.client import PolyaxonClient, ProjectClient
@@ -168,6 +170,7 @@ def list_project_versions(
168
170
 
169
171
  def register_project_version(
170
172
  owner: str,
173
+ team: Optional[str],
171
174
  project_name: str,
172
175
  version: str,
173
176
  kind: V1ProjectVersionKind,
@@ -207,7 +210,9 @@ def register_project_version(
207
210
  Printer.print(
208
211
  "You can view this version on Polyaxon UI: {}".format(
209
212
  get_dashboard_url(
210
- subpath="{}/{}/{}s/{}".format(owner, project_name, kind, version)
213
+ subpath="{}/{}s/{}".format(
214
+ get_project_subpath_url(owner, team, project_name), kind, version
215
+ )
211
216
  )
212
217
  )
213
218
  )
@@ -215,6 +220,7 @@ def register_project_version(
215
220
 
216
221
  def copy_project_version(
217
222
  owner: str,
223
+ team: Optional[str],
218
224
  project_name: str,
219
225
  version: str,
220
226
  kind: V1ProjectVersionKind,
@@ -259,8 +265,10 @@ def copy_project_version(
259
265
  Printer.print(
260
266
  "You can view this version on Polyaxon UI: {}".format(
261
267
  get_dashboard_url(
262
- subpath="{}/{}/{}s/{}".format(
263
- 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,
264
272
  )
265
273
  )
266
274
  )
@@ -269,6 +277,7 @@ def copy_project_version(
269
277
 
270
278
  def get_project_version(
271
279
  owner: str,
280
+ team: Optional[str],
272
281
  project_name: str,
273
282
  kind: V1ProjectVersionKind,
274
283
  version: str,
@@ -286,6 +295,17 @@ def get_project_version(
286
295
  try:
287
296
  response = polyaxon_client.get_version(kind, version)
288
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
+ )
289
309
  except (ApiException, HTTPError) as e:
290
310
  handle_cli_error(
291
311
  e,
@@ -468,13 +488,16 @@ def stage_project_version(
468
488
 
469
489
  def open_project_version_dashboard(
470
490
  owner: str,
491
+ team: Optional[str],
471
492
  project_name: str,
472
493
  kind: V1ProjectVersionKind,
473
494
  version: str,
474
495
  url: str,
475
496
  yes: bool = False,
476
497
  ):
477
- subpath = "{}/{}/{}s/{}".format(owner, project_name, kind, version)
498
+ subpath = "{}/{}s/{}".format(
499
+ get_project_subpath_url(owner, team, project_name), kind, version
500
+ )
478
501
 
479
502
  artifact_url = get_dashboard_url(subpath=subpath)
480
503
  if url:
@@ -526,7 +549,7 @@ def pull_one_or_many_project_versions(
526
549
  owner: str,
527
550
  project_name: str,
528
551
  kind: V1ProjectVersionKind,
529
- version: str,
552
+ version: Optional[str] = None,
530
553
  all_versions: Optional[bool] = None,
531
554
  query: Optional[str] = None,
532
555
  limit: Optional[int] = None,
@@ -566,3 +589,113 @@ def pull_one_or_many_project_versions(
566
589
  "or pass the flag `-a/--all` to pull versions.",
567
590
  sys_exit=True,
568
591
  )
592
+
593
+
594
+ def push_project_version(
595
+ owner: str,
596
+ project_name: str,
597
+ kind: V1ProjectVersionKind,
598
+ version: str,
599
+ path: str,
600
+ reset_project: bool = False,
601
+ force: bool = False,
602
+ clean: bool = False,
603
+ sys_exit: bool = False,
604
+ ):
605
+ fqn_version = get_versioned_entity_full_name(owner, project_name, version)
606
+ polyaxon_client = ProjectClient(
607
+ owner=owner, project=project_name, manual_exceptions_handling=True
608
+ )
609
+
610
+ try:
611
+ try:
612
+ polyaxon_client.load_offline_version(
613
+ kind=kind,
614
+ version=version,
615
+ path=path,
616
+ project_client=polyaxon_client,
617
+ reset_project=reset_project,
618
+ raise_if_not_found=True,
619
+ )
620
+ except Exception as _:
621
+ Printer.error(
622
+ "Could not load offline version `{}`.".format(version),
623
+ sys_exit=sys_exit,
624
+ )
625
+ return
626
+
627
+ Printer.header(
628
+ "Pushing {} version [white]`{}`[/white] ...".format(kind, fqn_version),
629
+ )
630
+ polyaxon_client.push_version(
631
+ kind,
632
+ version,
633
+ path=path,
634
+ force=force,
635
+ clean=clean,
636
+ )
637
+ Printer.success(
638
+ "Finished pushing the {} version `{}` from `{}`".format(
639
+ kind, fqn_version, path
640
+ )
641
+ )
642
+ except (ApiException, HTTPError) as e:
643
+ handle_cli_error(
644
+ e,
645
+ message="Could not push the {} version `{}`".format(kind, fqn_version),
646
+ )
647
+
648
+
649
+ def push_one_or_many_project_versions(
650
+ owner: str,
651
+ project_name: str,
652
+ kind: V1ProjectVersionKind,
653
+ path: str,
654
+ version: Optional[str] = None,
655
+ all_versions: Optional[bool] = None,
656
+ reset_project: bool = False,
657
+ force: bool = False,
658
+ clean: bool = False,
659
+ ):
660
+ def _push(version_name: str):
661
+ push_project_version(
662
+ owner=owner,
663
+ project_name=project_name,
664
+ kind=kind,
665
+ version=version_name,
666
+ path=path,
667
+ reset_project=reset_project,
668
+ force=force,
669
+ clean=clean,
670
+ )
671
+
672
+ offline_path = get_offline_base_path(
673
+ entity_kind=kind,
674
+ path=path,
675
+ )
676
+
677
+ if all_versions:
678
+ if (
679
+ not os.path.exists(offline_path)
680
+ or not os.path.isdir(offline_path)
681
+ or not os.listdir(offline_path)
682
+ ):
683
+ Printer.error(
684
+ f"Could not push offline {kind} versions, the path `{offline_path}` "
685
+ f"does not exist, is not a directory, or is empty."
686
+ )
687
+ sys.exit(1)
688
+ version_paths = os.listdir(offline_path)
689
+ Printer.header(
690
+ f"Pushing local {kind} versions (total: {len(version_paths)}) ..."
691
+ )
692
+ for idx, uid in enumerate(version_paths):
693
+ Printer.heading(f"Pushing {kind} version {idx + 1}/{len(offline_path)} ...")
694
+ _push(uid)
695
+ elif version:
696
+ _push(version)
697
+ else:
698
+ Printer.error(
699
+ "Please provide a version name, or pass the flag `-a/--all` to pull versions.",
700
+ sys_exit=True,
701
+ )
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
@@ -1,4 +1,5 @@
1
1
  import sys
2
+ import time
2
3
 
3
4
  from collections import namedtuple
4
5
  from typing import Dict, List, Optional
@@ -10,10 +11,11 @@ from clipped.utils import git as git_utils
10
11
  from clipped.utils.validation import validate_tags
11
12
  from urllib3.exceptions import HTTPError
12
13
 
13
- from polyaxon._cli.dashboard import get_dashboard_url
14
+ from polyaxon._cli.dashboard import get_dashboard_url, get_project_subpath_url
14
15
  from polyaxon._cli.errors import handle_cli_error
15
16
  from polyaxon._cli.operations import approve
16
17
  from polyaxon._cli.operations import execute as run_execute
18
+ from polyaxon._cli.operations import get_op_agent_host
17
19
  from polyaxon._cli.operations import logs as run_logs
18
20
  from polyaxon._cli.operations import shell as run_shell
19
21
  from polyaxon._cli.operations import statuses
@@ -30,6 +32,7 @@ from polyaxon._polyaxonfile import check_polyaxonfile
30
32
  from polyaxon._runner.kinds import RunnerKind
31
33
  from polyaxon._schemas.lifecycle import ManagedBy
32
34
  from polyaxon._utils import cache
35
+ from polyaxon._utils.fqn_utils import get_owner_team_space
33
36
  from polyaxon.client import RunClient
34
37
  from polyaxon.exceptions import ApiException
35
38
  from polyaxon.logger import clean_outputs
@@ -43,6 +46,7 @@ def _run(
43
46
  ctx,
44
47
  name: str,
45
48
  owner: str,
49
+ team: Optional[str],
46
50
  project_name: str,
47
51
  description: str,
48
52
  tags: List[str],
@@ -53,6 +57,7 @@ def _run(
53
57
  upload_to: str,
54
58
  upload_from: str,
55
59
  watch: bool,
60
+ approve_after: Optional[int] = None,
56
61
  output: Optional[str] = None,
57
62
  local: Optional[bool] = False,
58
63
  executor: Optional[RunnerKind] = None,
@@ -61,11 +66,14 @@ def _run(
61
66
  owner=owner, project=project_name, manual_exceptions_handling=True
62
67
  )
63
68
 
69
+ owner_team = get_owner_team_space(owner, team)
70
+ project_url = get_project_subpath_url(owner, team, project_name)
71
+
64
72
  def get_instance_info(r):
65
73
  rn = (
66
74
  f"[white]{r.name}[/white]@[white]{r.uuid}[/white]"
67
75
  if r.name
68
- else "[white]{r.uuid}[/white]"
76
+ else f"[white]{r.uuid}[/white]"
69
77
  )
70
78
  return f"[white]{owner}[/white]/[white]{project_name}[/white]:{rn}"
71
79
 
@@ -93,8 +101,9 @@ def _run(
93
101
  meta_info=meta_info,
94
102
  pending=pending,
95
103
  )
104
+ host_kwargs = get_op_agent_host(response.settings)
96
105
  run_url = get_dashboard_url(
97
- subpath="{}/{}/runs/{}".format(owner, project_name, response.uuid)
106
+ subpath="{}/runs/{}".format(project_url, response.uuid), **host_kwargs
98
107
  )
99
108
  if output:
100
109
  response_data = polyaxon_client.client.sanitize_for_serialization(
@@ -125,29 +134,44 @@ def _run(
125
134
 
126
135
  def execute_run_locally(run_uuid: str):
127
136
  ctx.obj = {
128
- "project": "{}/{}".format(owner, project_name),
137
+ "project": "{}/{}".format(owner_team, project_name),
129
138
  "run_uuid": run_uuid,
130
139
  "executor": executor,
131
140
  }
132
141
  ctx.invoke(run_execute)
133
142
 
134
143
  def watch_run_statuses(run_uuid: str):
135
- ctx.obj = {"project": "{}/{}".format(owner, project_name), "run_uuid": run_uuid}
144
+ ctx.obj = {
145
+ "project": "{}/{}".format(owner_team, project_name),
146
+ "run_uuid": run_uuid,
147
+ }
136
148
  ctx.invoke(statuses, watch=True)
137
149
 
138
150
  def watch_run_logs(run_uuid: str):
139
- ctx.obj = {"project": "{}/{}".format(owner, project_name), "run_uuid": run_uuid}
151
+ ctx.obj = {
152
+ "project": "{}/{}".format(owner_team, project_name),
153
+ "run_uuid": run_uuid,
154
+ }
140
155
  ctx.invoke(run_logs)
141
156
 
142
157
  def start_run_shell(run_uuid: str):
143
- ctx.obj = {"project": "{}/{}".format(owner, project_name), "run_uuid": run_uuid}
158
+ ctx.obj = {
159
+ "project": "{}/{}".format(owner_team, project_name),
160
+ "run_uuid": run_uuid,
161
+ }
144
162
  ctx.invoke(run_shell)
145
163
 
146
164
  def upload_run(run_uuid: str):
147
- ctx.obj = {"project": "{}/{}".format(owner, project_name), "run_uuid": run_uuid}
165
+ ctx.obj = {
166
+ "project": "{}/{}".format(owner_team, project_name),
167
+ "run_uuid": run_uuid,
168
+ }
148
169
  ctx.invoke(
149
170
  run_upload, path_to=upload_to, path_from=upload_from, sync_failure=True
150
171
  )
172
+ if approve_after and approve_after > 0:
173
+ Printer.print(f"Waiting {approve_after}s to approve the run...")
174
+ time.sleep(approve_after)
151
175
  ctx.invoke(approve)
152
176
 
153
177
  if not output:
@@ -356,11 +380,18 @@ def _run(
356
380
  )
357
381
  @click.option(
358
382
  "--approved",
383
+ "-ap",
359
384
  help="To enable/disable human in the loop validation without changing the polyaxonfile, "
360
385
  "similar to 'isApproved: true/false'. "
361
386
  "Can be used with yes/no, y/n, false/true, f/t, 1/0. "
362
387
  "e.g. '--approved=1', '--approved=yes', '--approved=false', '--approved=t', ...",
363
388
  )
389
+ @click.option(
390
+ "--approve-after",
391
+ "-aa",
392
+ type=int,
393
+ help="To delay or automatically approve a run after a certain number of seconds.",
394
+ )
364
395
  @click.option(
365
396
  "--git-preset",
366
397
  is_flag=True,
@@ -422,6 +453,7 @@ def run(
422
453
  nocache,
423
454
  cache,
424
455
  approved,
456
+ approve_after,
425
457
  git_preset,
426
458
  git_revision,
427
459
  ignore_template,
@@ -555,13 +587,14 @@ def run(
555
587
  Printer.print("Please customize the specification or disable the template!")
556
588
  sys.exit(1)
557
589
 
558
- owner, project_name = get_project_or_local(project, is_cli=True)
590
+ owner, team, project_name = get_project_or_local(project, is_cli=True)
559
591
  tags = validate_tags(tags, validate_yaml=True)
560
592
 
561
593
  _run(
562
594
  ctx=ctx,
563
595
  name=name,
564
596
  owner=owner,
597
+ team=team,
565
598
  project_name=project_name,
566
599
  description=description,
567
600
  tags=tags,
@@ -571,6 +604,7 @@ def run(
571
604
  upload_to=upload_to,
572
605
  upload_from=upload_from,
573
606
  watch=watch,
607
+ approve_after=approve_after,
574
608
  output=output,
575
609
  shell=shell,
576
610
  local=local,
@@ -33,7 +33,7 @@ def agent():
33
33
  help="Number of times to retry the process.",
34
34
  )
35
35
  @coroutine
36
- async def start(kind, max_retries, max_interval):
36
+ async def start(kind, max_interval, max_retries):
37
37
  from polyaxon import settings
38
38
  from polyaxon._env_vars.getters import get_agent_info
39
39
  from polyaxon._runner.kinds import RunnerKind
@@ -65,7 +65,7 @@ async def start(kind, max_retries, max_interval):
65
65
  await ag.start()
66
66
  return
67
67
  except Exception as e:
68
- logger.warning("Polyaxon agent retrying, error %s", e)
68
+ logger.warning("Polyaxon agent retrying, error %r", e)
69
69
  retry += 1
70
70
 
71
71
 
polyaxon/_cli/version.py CHANGED
@@ -21,7 +21,10 @@ def pip_upgrade(project_name=PROJECT_CLI_NAME):
21
21
 
22
22
 
23
23
  def get_version(package: str, show_error: bool = True):
24
- import pkg_resources
24
+ try:
25
+ import pkg_resources
26
+ except ImportError:
27
+ return
25
28
 
26
29
  try:
27
30
  return pkg_resources.get_distribution(package).version
@@ -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