cgcsdk 1.0.6__tar.gz → 1.0.7__tar.gz
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.
- cgcsdk-1.0.7/PKG-INFO +70 -0
- cgcsdk-1.0.7/README.md +34 -0
- {cgcsdk-1.0.6 → cgcsdk-1.0.7}/cgc/.env +1 -1
- {cgcsdk-1.0.6 → cgcsdk-1.0.7}/cgc/CHANGELOG.md +11 -0
- {cgcsdk-1.0.6 → cgcsdk-1.0.7}/cgc/cgc.py +5 -1
- {cgcsdk-1.0.6 → cgcsdk-1.0.7}/cgc/commands/cgc_cmd.py +28 -3
- {cgcsdk-1.0.6 → cgcsdk-1.0.7}/cgc/commands/cgc_cmd_responses.py +8 -0
- {cgcsdk-1.0.6 → cgcsdk-1.0.7}/cgc/commands/compute/compute_models.py +2 -0
- {cgcsdk-1.0.6 → cgcsdk-1.0.7}/cgc/commands/compute/compute_utills.py +16 -6
- cgcsdk-1.0.7/cgc/commands/jobs/__init__.py +10 -0
- cgcsdk-1.0.7/cgc/commands/jobs/job_utils.py +175 -0
- cgcsdk-1.0.7/cgc/commands/jobs/jobs_cmd.py +238 -0
- cgcsdk-1.0.7/cgc/commands/jobs/jobs_responses.py +52 -0
- {cgcsdk-1.0.6 → cgcsdk-1.0.7}/cgc/sdk/__init__.py +1 -0
- cgcsdk-1.0.7/cgc/sdk/job.py +147 -0
- {cgcsdk-1.0.6 → cgcsdk-1.0.7}/cgc/sdk/resource.py +1 -0
- {cgcsdk-1.0.6 → cgcsdk-1.0.7}/cgc/utils/custom_exceptions.py +5 -1
- cgcsdk-1.0.7/cgcsdk.egg-info/PKG-INFO +70 -0
- {cgcsdk-1.0.6 → cgcsdk-1.0.7}/cgcsdk.egg-info/SOURCES.txt +5 -0
- cgcsdk-1.0.6/PKG-INFO +0 -39
- cgcsdk-1.0.6/README.md +0 -3
- cgcsdk-1.0.6/cgcsdk.egg-info/PKG-INFO +0 -39
- {cgcsdk-1.0.6 → cgcsdk-1.0.7}/LICENSE +0 -0
- {cgcsdk-1.0.6 → cgcsdk-1.0.7}/MANIFEST.in +0 -0
- {cgcsdk-1.0.6 → cgcsdk-1.0.7}/cgc/__init__.py +0 -0
- {cgcsdk-1.0.6 → cgcsdk-1.0.7}/cgc/commands/__init__.py +0 -0
- {cgcsdk-1.0.6 → cgcsdk-1.0.7}/cgc/commands/auth/__init__.py +0 -0
- {cgcsdk-1.0.6 → cgcsdk-1.0.7}/cgc/commands/auth/auth_cmd.py +0 -0
- {cgcsdk-1.0.6 → cgcsdk-1.0.7}/cgc/commands/auth/auth_responses.py +0 -0
- {cgcsdk-1.0.6 → cgcsdk-1.0.7}/cgc/commands/auth/auth_utils.py +0 -0
- {cgcsdk-1.0.6 → cgcsdk-1.0.7}/cgc/commands/billing/__init__.py +0 -0
- {cgcsdk-1.0.6 → cgcsdk-1.0.7}/cgc/commands/billing/billing_cmd.py +0 -0
- {cgcsdk-1.0.6 → cgcsdk-1.0.7}/cgc/commands/billing/billing_responses.py +0 -0
- {cgcsdk-1.0.6 → cgcsdk-1.0.7}/cgc/commands/billing/billing_utils.py +0 -0
- {cgcsdk-1.0.6 → cgcsdk-1.0.7}/cgc/commands/cgc_helpers.py +0 -0
- {cgcsdk-1.0.6 → cgcsdk-1.0.7}/cgc/commands/compute/__init__.py +0 -0
- {cgcsdk-1.0.6 → cgcsdk-1.0.7}/cgc/commands/compute/compute_cmd.py +0 -0
- {cgcsdk-1.0.6 → cgcsdk-1.0.7}/cgc/commands/compute/compute_responses.py +0 -0
- {cgcsdk-1.0.6 → cgcsdk-1.0.7}/cgc/commands/db/__init__.py +0 -0
- {cgcsdk-1.0.6 → cgcsdk-1.0.7}/cgc/commands/db/db_cmd.py +0 -0
- {cgcsdk-1.0.6 → cgcsdk-1.0.7}/cgc/commands/debug/__init__.py +0 -0
- {cgcsdk-1.0.6 → cgcsdk-1.0.7}/cgc/commands/debug/debug_cmd.py +0 -0
- {cgcsdk-1.0.6 → cgcsdk-1.0.7}/cgc/commands/exceptions.py +0 -0
- {cgcsdk-1.0.6 → cgcsdk-1.0.7}/cgc/commands/resource/__init__.py +0 -0
- {cgcsdk-1.0.6 → cgcsdk-1.0.7}/cgc/commands/resource/resource_cmd.py +0 -0
- {cgcsdk-1.0.6 → cgcsdk-1.0.7}/cgc/commands/resource/resource_responses.py +0 -0
- {cgcsdk-1.0.6 → cgcsdk-1.0.7}/cgc/commands/volume/__init__.py +0 -0
- {cgcsdk-1.0.6 → cgcsdk-1.0.7}/cgc/commands/volume/data_model.py +0 -0
- {cgcsdk-1.0.6 → cgcsdk-1.0.7}/cgc/commands/volume/volume_cmd.py +0 -0
- {cgcsdk-1.0.6 → cgcsdk-1.0.7}/cgc/commands/volume/volume_responses.py +0 -0
- {cgcsdk-1.0.6 → cgcsdk-1.0.7}/cgc/commands/volume/volume_utils.py +0 -0
- {cgcsdk-1.0.6 → cgcsdk-1.0.7}/cgc/config.py +0 -0
- {cgcsdk-1.0.6 → cgcsdk-1.0.7}/cgc/sdk/exceptions.py +0 -0
- {cgcsdk-1.0.6 → cgcsdk-1.0.7}/cgc/sdk/handlers.py +0 -0
- {cgcsdk-1.0.6 → cgcsdk-1.0.7}/cgc/sdk/mongodb.py +0 -0
- {cgcsdk-1.0.6 → cgcsdk-1.0.7}/cgc/sdk/postgresql.py +0 -0
- {cgcsdk-1.0.6 → cgcsdk-1.0.7}/cgc/sdk/redis.py +0 -0
- {cgcsdk-1.0.6 → cgcsdk-1.0.7}/cgc/server.crt +0 -0
- {cgcsdk-1.0.6 → cgcsdk-1.0.7}/cgc/telemetry/__init__.py +0 -0
- {cgcsdk-1.0.6 → cgcsdk-1.0.7}/cgc/telemetry/basic.py +0 -0
- {cgcsdk-1.0.6 → cgcsdk-1.0.7}/cgc/tests/__init__.py +0 -0
- {cgcsdk-1.0.6 → cgcsdk-1.0.7}/cgc/tests/desired_responses/test_billing_invoice.txt +0 -0
- {cgcsdk-1.0.6 → cgcsdk-1.0.7}/cgc/tests/desired_responses/test_billing_status.txt +0 -0
- {cgcsdk-1.0.6 → cgcsdk-1.0.7}/cgc/tests/desired_responses/test_billing_stop_events_compute.txt +0 -0
- {cgcsdk-1.0.6 → cgcsdk-1.0.7}/cgc/tests/desired_responses/test_billing_stop_events_volume.txt +0 -0
- {cgcsdk-1.0.6 → cgcsdk-1.0.7}/cgc/tests/desired_responses/test_compute_list.txt +0 -0
- {cgcsdk-1.0.6 → cgcsdk-1.0.7}/cgc/tests/desired_responses/test_compute_list_no_labels.txt +0 -0
- {cgcsdk-1.0.6 → cgcsdk-1.0.7}/cgc/tests/desired_responses/test_tabulate_response.txt +0 -0
- {cgcsdk-1.0.6 → cgcsdk-1.0.7}/cgc/tests/desired_responses/test_volume_list.txt +0 -0
- {cgcsdk-1.0.6 → cgcsdk-1.0.7}/cgc/tests/responses_tests.py +0 -0
- {cgcsdk-1.0.6 → cgcsdk-1.0.7}/cgc/utils/__init__.py +0 -0
- {cgcsdk-1.0.6 → cgcsdk-1.0.7}/cgc/utils/click_group.py +0 -0
- {cgcsdk-1.0.6 → cgcsdk-1.0.7}/cgc/utils/config_utils.py +0 -0
- {cgcsdk-1.0.6 → cgcsdk-1.0.7}/cgc/utils/consts/__init__.py +0 -0
- {cgcsdk-1.0.6 → cgcsdk-1.0.7}/cgc/utils/consts/env_consts.py +0 -0
- {cgcsdk-1.0.6 → cgcsdk-1.0.7}/cgc/utils/consts/message_consts.py +0 -0
- {cgcsdk-1.0.6 → cgcsdk-1.0.7}/cgc/utils/cryptography/__init__.py +0 -0
- {cgcsdk-1.0.6 → cgcsdk-1.0.7}/cgc/utils/cryptography/aes_crypto.py +0 -0
- {cgcsdk-1.0.6 → cgcsdk-1.0.7}/cgc/utils/cryptography/encryption_module.py +0 -0
- {cgcsdk-1.0.6 → cgcsdk-1.0.7}/cgc/utils/cryptography/rsa_crypto.py +0 -0
- {cgcsdk-1.0.6 → cgcsdk-1.0.7}/cgc/utils/message_utils.py +0 -0
- {cgcsdk-1.0.6 → cgcsdk-1.0.7}/cgc/utils/prepare_headers.py +0 -0
- {cgcsdk-1.0.6 → cgcsdk-1.0.7}/cgc/utils/requests_helper.py +0 -0
- {cgcsdk-1.0.6 → cgcsdk-1.0.7}/cgc/utils/response_utils.py +0 -0
- {cgcsdk-1.0.6 → cgcsdk-1.0.7}/cgc/utils/update.py +0 -0
- {cgcsdk-1.0.6 → cgcsdk-1.0.7}/cgc/utils/version_control.py +0 -0
- {cgcsdk-1.0.6 → cgcsdk-1.0.7}/cgcsdk.egg-info/dependency_links.txt +0 -0
- {cgcsdk-1.0.6 → cgcsdk-1.0.7}/cgcsdk.egg-info/entry_points.txt +0 -0
- {cgcsdk-1.0.6 → cgcsdk-1.0.7}/cgcsdk.egg-info/requires.txt +0 -0
- {cgcsdk-1.0.6 → cgcsdk-1.0.7}/cgcsdk.egg-info/top_level.txt +0 -0
- {cgcsdk-1.0.6 → cgcsdk-1.0.7}/pyproject.toml +0 -0
- {cgcsdk-1.0.6 → cgcsdk-1.0.7}/setup.cfg +0 -0
- {cgcsdk-1.0.6 → cgcsdk-1.0.7}/setup.py +0 -0
cgcsdk-1.0.7/PKG-INFO
ADDED
@@ -0,0 +1,70 @@
|
|
1
|
+
Metadata-Version: 2.1
|
2
|
+
Name: cgcsdk
|
3
|
+
Version: 1.0.7
|
4
|
+
Summary: Comtegra GPU Cloud REST API client
|
5
|
+
Author: Comtegra AI Team
|
6
|
+
Author-email: ai@comtegra.pl
|
7
|
+
License: BSD 2-clause
|
8
|
+
Project-URL: Documentation, https://example.com/documentation/
|
9
|
+
Project-URL: GitHub, https://github.com/foobar/foobar/
|
10
|
+
Project-URL: Changelog, https://github.com/foobar/foobar/blob/master/CHANGELOG.md
|
11
|
+
Keywords: cloud,sdk,orchestrator,kubernetes,jupyter-notebook
|
12
|
+
Classifier: Development Status :: 1 - Planning
|
13
|
+
Classifier: Intended Audience :: Science/Research
|
14
|
+
Classifier: License :: OSI Approved :: BSD License
|
15
|
+
Classifier: Operating System :: POSIX :: Linux
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
17
|
+
Classifier: Programming Language :: Python :: 3.4
|
18
|
+
Classifier: Programming Language :: Python :: 3.5
|
19
|
+
Classifier: Programming Language :: Python :: 3.8
|
20
|
+
Classifier: Programming Language :: Python :: 3.9
|
21
|
+
Classifier: Programming Language :: Python :: 3.10
|
22
|
+
Description-Content-Type: text/markdown
|
23
|
+
License-File: LICENSE
|
24
|
+
Requires-Dist: click
|
25
|
+
Requires-Dist: python-dotenv
|
26
|
+
Requires-Dist: tabulate
|
27
|
+
Requires-Dist: pycryptodomex
|
28
|
+
Requires-Dist: paramiko>=2.11
|
29
|
+
Requires-Dist: statsd
|
30
|
+
Requires-Dist: requests
|
31
|
+
Requires-Dist: setuptools
|
32
|
+
Requires-Dist: colorama
|
33
|
+
Requires-Dist: redis
|
34
|
+
Requires-Dist: pymongo
|
35
|
+
Requires-Dist: psycopg2-binary
|
36
|
+
|
37
|
+
# Comtegra GPU Cloud CLI Client
|
38
|
+
|
39
|
+
## Basic info
|
40
|
+
|
41
|
+
CGC Clinet is complete solution to create and manage your compute resources through CLI interface and python code. It incorporates CLI and SDK in one package.
|
42
|
+
|
43
|
+
CGC CLI is a command line interface for Comtegra GPU Cloud. CGC CLI enables management of your Comtegra GPU Cloud resources. Current version of the app provides support for compute, storage and network resurces to be created, listed and deleted. Every compute resource is given to you as an URL, which is accessible from open Internet.
|
44
|
+
|
45
|
+
To enable better access to your storage resources, every account has the ability to spawn free of charge filebrowser which is local implementation of dropbox. Remember to mount newely created volumes to it.
|
46
|
+
|
47
|
+
For now, we provide the ability to spawn compute resources like:
|
48
|
+
|
49
|
+
1. [Jupyter notebook](https://jupyter.org/) with tensorflow or pytorch installed as default
|
50
|
+
2. [Triton inferencing server](https://docs.nvidia.com/deeplearning/triton-inference-server/) for large scale inferencing
|
51
|
+
3. [Label studio](https://labelstud.io/) for easy management of your data annotation tasks with variety of modes
|
52
|
+
4. [Rapids](https://rapids.ai/) suite of accelerated libraries for data processing
|
53
|
+
|
54
|
+
Notebooks are equiped with all CUDA libraries and GPU drivers which enables the usage of GPU for accelerated computations.
|
55
|
+
Apart from compute resources, we provide the database engines accessible from within your namespace:
|
56
|
+
|
57
|
+
1. [MongoDB](https://www.mongodb.org/)
|
58
|
+
2. [PostgreSQL](https://www.postgresql.org/)
|
59
|
+
3. [Redis](https://redis.io/)
|
60
|
+
4. [Weaviate](https://weaviate.io/)
|
61
|
+
|
62
|
+
More are coming!
|
63
|
+
Please follow instructions to get started.
|
64
|
+
|
65
|
+
## More info
|
66
|
+
|
67
|
+
If you'd like to know more visit:
|
68
|
+
|
69
|
+
- [Comtegra GPU Website](https://cgc.comtegra.cloud)
|
70
|
+
- [Docs](https://docs.cgc.comtegra.cloud)
|
cgcsdk-1.0.7/README.md
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
# Comtegra GPU Cloud CLI Client
|
2
|
+
|
3
|
+
## Basic info
|
4
|
+
|
5
|
+
CGC Clinet is complete solution to create and manage your compute resources through CLI interface and python code. It incorporates CLI and SDK in one package.
|
6
|
+
|
7
|
+
CGC CLI is a command line interface for Comtegra GPU Cloud. CGC CLI enables management of your Comtegra GPU Cloud resources. Current version of the app provides support for compute, storage and network resurces to be created, listed and deleted. Every compute resource is given to you as an URL, which is accessible from open Internet.
|
8
|
+
|
9
|
+
To enable better access to your storage resources, every account has the ability to spawn free of charge filebrowser which is local implementation of dropbox. Remember to mount newely created volumes to it.
|
10
|
+
|
11
|
+
For now, we provide the ability to spawn compute resources like:
|
12
|
+
|
13
|
+
1. [Jupyter notebook](https://jupyter.org/) with tensorflow or pytorch installed as default
|
14
|
+
2. [Triton inferencing server](https://docs.nvidia.com/deeplearning/triton-inference-server/) for large scale inferencing
|
15
|
+
3. [Label studio](https://labelstud.io/) for easy management of your data annotation tasks with variety of modes
|
16
|
+
4. [Rapids](https://rapids.ai/) suite of accelerated libraries for data processing
|
17
|
+
|
18
|
+
Notebooks are equiped with all CUDA libraries and GPU drivers which enables the usage of GPU for accelerated computations.
|
19
|
+
Apart from compute resources, we provide the database engines accessible from within your namespace:
|
20
|
+
|
21
|
+
1. [MongoDB](https://www.mongodb.org/)
|
22
|
+
2. [PostgreSQL](https://www.postgresql.org/)
|
23
|
+
3. [Redis](https://redis.io/)
|
24
|
+
4. [Weaviate](https://weaviate.io/)
|
25
|
+
|
26
|
+
More are coming!
|
27
|
+
Please follow instructions to get started.
|
28
|
+
|
29
|
+
## More info
|
30
|
+
|
31
|
+
If you'd like to know more visit:
|
32
|
+
|
33
|
+
- [Comtegra GPU Website](https://cgc.comtegra.cloud)
|
34
|
+
- [Docs](https://docs.cgc.comtegra.cloud)
|
@@ -1,5 +1,16 @@
|
|
1
1
|
# Change Log
|
2
2
|
|
3
|
+
## 1.0.7
|
4
|
+
|
5
|
+
Release on April 04, 2024
|
6
|
+
|
7
|
+
* speed of resource creation with volumes / shared memory, has been improved
|
8
|
+
* added jobs creation: cgc job create
|
9
|
+
* added jobs list: cgc job list
|
10
|
+
* added jobs delete: cgc job delete
|
11
|
+
* added logs (STDOUT, STDERR) reader for spawned applications: cgc logs
|
12
|
+
* added SDK for logs & jobs
|
13
|
+
|
3
14
|
## 1.0.6
|
4
15
|
|
5
16
|
Release on March 13, 2024
|
@@ -4,6 +4,7 @@ from cgc.commands.compute.compute_cmd import compute_group
|
|
4
4
|
from cgc.commands.billing.billing_cmd import billing_group
|
5
5
|
from cgc.commands.db.db_cmd import db_group
|
6
6
|
from cgc.commands.resource.resource_cmd import resource_group
|
7
|
+
from cgc.commands.jobs.jobs_cmd import job_group
|
7
8
|
from cgc.commands.auth.auth_cmd import (
|
8
9
|
api_keys_group,
|
9
10
|
auth_register,
|
@@ -13,10 +14,12 @@ from cgc.commands.debug.debug_cmd import debug_group
|
|
13
14
|
from cgc.commands.cgc_cmd import (
|
14
15
|
cgc_rm,
|
15
16
|
cgc_status,
|
17
|
+
cgc_logs,
|
16
18
|
sending_telemetry_permission,
|
17
19
|
resource_events,
|
18
20
|
context_group,
|
19
21
|
)
|
22
|
+
|
20
23
|
from cgc.utils.version_control import check_version, _get_version
|
21
24
|
from cgc.utils.click_group import CustomGroup
|
22
25
|
|
@@ -41,7 +44,8 @@ cli.add_command(resource_group)
|
|
41
44
|
cli.add_command(billing_group)
|
42
45
|
cli.add_command(cgc_status)
|
43
46
|
cli.add_command(sending_telemetry_permission)
|
44
|
-
|
47
|
+
cli.add_command(cgc_logs)
|
48
|
+
cli.add_command(job_group)
|
45
49
|
|
46
50
|
if __name__ == "__main__" or __name__ == "cgc.cgc":
|
47
51
|
cli()
|
@@ -1,7 +1,10 @@
|
|
1
1
|
import click
|
2
2
|
import json
|
3
3
|
|
4
|
-
from cgc.commands.cgc_cmd_responses import
|
4
|
+
from cgc.commands.cgc_cmd_responses import (
|
5
|
+
cgc_logs_response,
|
6
|
+
cgc_status_response,
|
7
|
+
)
|
5
8
|
from cgc.commands.resource.resource_cmd import resource_delete
|
6
9
|
from cgc.utils.requests_helper import call_api, EndpointTypes
|
7
10
|
from cgc.utils.click_group import CustomCommand, CustomGroup
|
@@ -9,7 +12,7 @@ from cgc.utils.prepare_headers import get_api_url_and_prepare_headers
|
|
9
12
|
from cgc.utils.response_utils import retrieve_and_validate_response_send_metric
|
10
13
|
from cgc.telemetry.basic import telemetry_permission_set
|
11
14
|
from cgc.commands.compute.compute_responses import compute_logs_response
|
12
|
-
from cgc.commands.auth.auth_cmd import auth_register
|
15
|
+
# from cgc.commands.auth.auth_cmd import auth_register
|
13
16
|
from cgc.utils import set_environment_data, check_if_config_exist, list_all_config_files
|
14
17
|
from cgc.commands.cgc_helpers import table_of_user_context_files
|
15
18
|
from cgc.utils.config_utils import config_path
|
@@ -37,7 +40,7 @@ def resource_events(app_name: str):
|
|
37
40
|
request=EndpointTypes.get,
|
38
41
|
url=url,
|
39
42
|
headers=headers,
|
40
|
-
data=json.dumps(__payload).encode(
|
43
|
+
data=json.dumps(__payload).encode("utf-8"),
|
41
44
|
)
|
42
45
|
click.echo(
|
43
46
|
compute_logs_response(retrieve_and_validate_response_send_metric(__res, metric))
|
@@ -122,3 +125,25 @@ def folder_of_contexts():
|
|
122
125
|
def get_env_path():
|
123
126
|
"""Displays current environment file path"""
|
124
127
|
click.echo(f"Current environment file path: {ENV_FILE_PATH}")
|
128
|
+
|
129
|
+
|
130
|
+
@click.command("logs", cls=CustomCommand)
|
131
|
+
@click.argument("app_name", type=click.STRING)
|
132
|
+
def cgc_logs(app_name):
|
133
|
+
"""Displays logs of a given app"""
|
134
|
+
|
135
|
+
if not app_name:
|
136
|
+
raise click.ClickException("Please provide a non-empty name")
|
137
|
+
|
138
|
+
api_url, headers = get_api_url_and_prepare_headers()
|
139
|
+
url = f"{api_url}/v1/api/resource/logs/{app_name}"
|
140
|
+
metric = "logs.get"
|
141
|
+
__res = call_api(
|
142
|
+
request=EndpointTypes.get,
|
143
|
+
url=url,
|
144
|
+
headers=headers,
|
145
|
+
)
|
146
|
+
|
147
|
+
click.echo(
|
148
|
+
cgc_logs_response(retrieve_and_validate_response_send_metric(__res, metric))
|
149
|
+
)
|
@@ -72,3 +72,11 @@ def cgc_status_response(data: dict):
|
|
72
72
|
),
|
73
73
|
headers=list_headers,
|
74
74
|
)
|
75
|
+
|
76
|
+
|
77
|
+
def cgc_logs_response(data: dict):
|
78
|
+
return "\n".join(
|
79
|
+
"==> %s/%s <==\n%s" % (pod, cont, log)
|
80
|
+
for pod, containers in data["details"]["logs"].items()
|
81
|
+
for cont, log in containers.items()
|
82
|
+
)
|
@@ -1,6 +1,6 @@
|
|
1
|
-
from ast import main
|
2
1
|
import cgc.utils.consts.env_consts as env_consts
|
3
2
|
|
3
|
+
|
4
4
|
def list_get_mounted_volumes_paths(volume_list: list) -> str:
|
5
5
|
"""Formats and returns list of PVC volumes mounted to an app.
|
6
6
|
|
@@ -20,6 +20,7 @@ def list_get_mounted_volumes_paths(volume_list: list) -> str:
|
|
20
20
|
)
|
21
21
|
return volumes_mounted
|
22
22
|
|
23
|
+
|
23
24
|
def list_get_mounted_volumes(volume_list: list) -> str:
|
24
25
|
"""Formats and returns list of PVC volumes mounted to an app.
|
25
26
|
|
@@ -39,16 +40,21 @@ def list_get_mounted_volumes(volume_list: list) -> str:
|
|
39
40
|
)
|
40
41
|
return volumes_mounted
|
41
42
|
|
42
|
-
|
43
|
+
|
44
|
+
def get_app_mounts(pod_list: list) -> list:
|
43
45
|
output_data = []
|
44
|
-
|
46
|
+
|
45
47
|
for pod in pod_list:
|
46
48
|
try:
|
47
|
-
main_container_name = pod["labels"]["entity"]
|
49
|
+
main_container_name = pod["labels"]["entity"]
|
48
50
|
try:
|
49
|
-
main_container = [
|
51
|
+
main_container = [
|
52
|
+
x for x in pod["containers"] if x["name"] == main_container_name
|
53
|
+
][0]
|
50
54
|
except IndexError:
|
51
|
-
raise Exception(
|
55
|
+
raise Exception(
|
56
|
+
"Parser was unable to find main container in server output in container list"
|
57
|
+
)
|
52
58
|
volumes_mounted = list_get_mounted_volumes(main_container["mounts"])
|
53
59
|
volumes_paths = list_get_mounted_volumes_paths(main_container["mounts"])
|
54
60
|
pod_data = {
|
@@ -63,6 +69,7 @@ def get_app_mounts(pod_list:list) -> list:
|
|
63
69
|
pass
|
64
70
|
return output_data
|
65
71
|
|
72
|
+
|
66
73
|
def get_app_list(pod_list: list, detailed: bool) -> list:
|
67
74
|
"""Formats and returns list of apps to print.
|
68
75
|
|
@@ -110,6 +117,9 @@ def get_app_list(pod_list: list, detailed: bool) -> list:
|
|
110
117
|
pod["labels"]["url"] = pod["labels"]["pod_url"]
|
111
118
|
pod["labels"].pop("app-token")
|
112
119
|
pod["labels"].pop("pod_url")
|
120
|
+
pod["labels"].pop("resource-type")
|
121
|
+
pod["labels"].pop("api-key-id", None)
|
122
|
+
pod["labels"].pop("user-id", None)
|
113
123
|
|
114
124
|
# appending the rest of labels
|
115
125
|
pod_data.update(pod["labels"])
|
@@ -0,0 +1,175 @@
|
|
1
|
+
from typing import Optional
|
2
|
+
from cgc.commands.compute.compute_utills import list_get_mounted_volumes
|
3
|
+
import cgc.utils.consts.env_consts as env_consts
|
4
|
+
|
5
|
+
|
6
|
+
def job_delete_payload(name):
|
7
|
+
"""
|
8
|
+
Create payload for job delete.
|
9
|
+
"""
|
10
|
+
payload = {
|
11
|
+
"name": name,
|
12
|
+
}
|
13
|
+
return payload
|
14
|
+
|
15
|
+
|
16
|
+
def job_create_payload(
|
17
|
+
name,
|
18
|
+
cpu,
|
19
|
+
memory,
|
20
|
+
volumes: list,
|
21
|
+
volume_full_path: str,
|
22
|
+
resource_data: list = [],
|
23
|
+
config_maps_data: list = [],
|
24
|
+
gpu: int = 0,
|
25
|
+
gpu_type: str = None,
|
26
|
+
shm_size: int = 0,
|
27
|
+
image_name: str = "",
|
28
|
+
startup_command: str = "",
|
29
|
+
repository_secret: str = "",
|
30
|
+
ttl_seconds_after_finished: Optional[int] = None,
|
31
|
+
):
|
32
|
+
"""
|
33
|
+
Create payload for app creation.
|
34
|
+
"""
|
35
|
+
extra_payload = {}
|
36
|
+
if shm_size is not None and shm_size != 0:
|
37
|
+
extra_payload["shared_memory"] = shm_size
|
38
|
+
|
39
|
+
if ttl_seconds_after_finished is not None:
|
40
|
+
extra_payload["ttl_seconds_after_finished"] = ttl_seconds_after_finished
|
41
|
+
|
42
|
+
payload = {
|
43
|
+
"resource_data": {
|
44
|
+
"name": name,
|
45
|
+
"cpu": cpu,
|
46
|
+
"gpu": gpu,
|
47
|
+
"memory": memory,
|
48
|
+
"gpu_type": gpu_type,
|
49
|
+
"full_mount_path": volume_full_path,
|
50
|
+
**extra_payload,
|
51
|
+
}
|
52
|
+
}
|
53
|
+
try:
|
54
|
+
if len(volumes) != 0:
|
55
|
+
if not volume_full_path:
|
56
|
+
payload["resource_data"]["pv_volume"] = volumes
|
57
|
+
elif volume_full_path and len(volumes) != 1:
|
58
|
+
raise Exception(
|
59
|
+
"Volume full path can only be used with a single volume"
|
60
|
+
)
|
61
|
+
else:
|
62
|
+
payload["resource_data"]["pv_volume"] = volumes
|
63
|
+
except TypeError:
|
64
|
+
pass
|
65
|
+
try:
|
66
|
+
resource_data_dict = {"resource_data": {}}
|
67
|
+
if len(resource_data) != 0:
|
68
|
+
for resource in resource_data:
|
69
|
+
try:
|
70
|
+
key, value = resource.split("=")
|
71
|
+
resource_data_dict["resource_data"][key] = value
|
72
|
+
except ValueError:
|
73
|
+
raise Exception(
|
74
|
+
"Invalid resource data format. Use key=value format"
|
75
|
+
)
|
76
|
+
if image_name:
|
77
|
+
resource_data_dict["resource_data"]["custom_image"] = image_name
|
78
|
+
if startup_command:
|
79
|
+
resource_data_dict["resource_data"]["custom_command"] = startup_command
|
80
|
+
if repository_secret:
|
81
|
+
resource_data_dict["resource_data"][
|
82
|
+
"image_pull_secret_name"
|
83
|
+
] = repository_secret
|
84
|
+
if resource_data_dict["resource_data"] != {}:
|
85
|
+
payload["template_specific_data"] = resource_data_dict
|
86
|
+
except TypeError:
|
87
|
+
pass
|
88
|
+
try:
|
89
|
+
if len(config_maps_data) != 0:
|
90
|
+
config_maps_data_dict = {}
|
91
|
+
for config_map in config_maps_data:
|
92
|
+
try:
|
93
|
+
key, value = config_map.split(
|
94
|
+
"="
|
95
|
+
) # where key is name of config map and value is data
|
96
|
+
config_maps_data_dict[key] = (
|
97
|
+
value # value is dict, ex.: {"key": "value"}
|
98
|
+
)
|
99
|
+
except ValueError:
|
100
|
+
raise Exception(
|
101
|
+
"Invalid config map data format. Use key=value format"
|
102
|
+
)
|
103
|
+
payload["config_maps_data"] = config_maps_data_dict
|
104
|
+
except TypeError:
|
105
|
+
pass
|
106
|
+
return payload
|
107
|
+
|
108
|
+
|
109
|
+
def get_job_list(job_pod_list: list, job_list: list):
|
110
|
+
list_of_json_data = get_job_pod_list(job_pod_list)
|
111
|
+
for json_data in list_of_json_data:
|
112
|
+
for job in job_list:
|
113
|
+
if job.get("name") == json_data.get("name"):
|
114
|
+
json_data["ttl_seconds_after_finished"] = job.get(
|
115
|
+
"ttl_seconds_after_finished", "N/A"
|
116
|
+
)
|
117
|
+
break
|
118
|
+
return list_of_json_data
|
119
|
+
|
120
|
+
|
121
|
+
def get_job_pod_list(job_pod_list: list) -> list:
|
122
|
+
"""Formats and returns list of jobs to print.
|
123
|
+
|
124
|
+
:param pod_list: list of pods
|
125
|
+
:type pod_list: list
|
126
|
+
:return: formatted list of apps
|
127
|
+
:rtype: list
|
128
|
+
"""
|
129
|
+
output_data = []
|
130
|
+
|
131
|
+
for pod in job_pod_list:
|
132
|
+
try:
|
133
|
+
main_container_name = "custom-job"
|
134
|
+
try:
|
135
|
+
main_container = [
|
136
|
+
x
|
137
|
+
for x in pod.get("containers", [])
|
138
|
+
if x.get("name") == main_container_name
|
139
|
+
][0]
|
140
|
+
except IndexError:
|
141
|
+
raise Exception(
|
142
|
+
"Parser was unable to find main container in server output in container list"
|
143
|
+
)
|
144
|
+
volumes_mounted = list_get_mounted_volumes(main_container.get("mounts", []))
|
145
|
+
limits = main_container.get("resources", {}).get("limits")
|
146
|
+
cpu = limits.get("cpu") if limits is not None else 0
|
147
|
+
ram = limits.get("memory") if limits is not None else "0Gi"
|
148
|
+
|
149
|
+
pod_data = {
|
150
|
+
"name": pod.get("labels", {}).get("app-name"),
|
151
|
+
"status": pod.get("status", {}),
|
152
|
+
"volumes_mounted": volumes_mounted,
|
153
|
+
"cpu": cpu,
|
154
|
+
"ram": ram,
|
155
|
+
"gpu-count": pod.get("labels", {}).get("gpu-count", 0),
|
156
|
+
"gpu-label": pod.get("labels", {}).get("gpu-label", "N/A"),
|
157
|
+
}
|
158
|
+
# getting rid of unwanted and used values
|
159
|
+
if "pod-template-hash" in pod["labels"].keys():
|
160
|
+
pod["labels"].pop("pod-template-hash")
|
161
|
+
pod["labels"].pop("app-name")
|
162
|
+
pod["labels"].pop("entity")
|
163
|
+
pod["labels"].pop("resource-type")
|
164
|
+
pod["labels"].pop("job-name")
|
165
|
+
pod["labels"].pop("controller-uid")
|
166
|
+
pod["labels"].pop("api-key-id", None)
|
167
|
+
pod["labels"].pop("user-id", None)
|
168
|
+
|
169
|
+
# appending the rest of labels
|
170
|
+
pod_data.update(pod["labels"])
|
171
|
+
output_data.append(pod_data)
|
172
|
+
except KeyError:
|
173
|
+
pass
|
174
|
+
|
175
|
+
return output_data
|