cgcsdk 1.0.6__tar.gz → 1.0.9__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.
Files changed (101) hide show
  1. cgcsdk-1.0.9/PKG-INFO +66 -0
  2. cgcsdk-1.0.9/README.md +32 -0
  3. {cgcsdk-1.0.6 → cgcsdk-1.0.9}/cgc/.env +1 -1
  4. {cgcsdk-1.0.6 → cgcsdk-1.0.9}/cgc/CHANGELOG.md +30 -0
  5. {cgcsdk-1.0.6 → cgcsdk-1.0.9}/cgc/cgc.py +7 -1
  6. {cgcsdk-1.0.6 → cgcsdk-1.0.9}/cgc/commands/auth/__init__.py +2 -2
  7. {cgcsdk-1.0.6 → cgcsdk-1.0.9}/cgc/commands/auth/auth_cmd.py +14 -2
  8. {cgcsdk-1.0.6 → cgcsdk-1.0.9}/cgc/commands/auth/auth_responses.py +9 -2
  9. {cgcsdk-1.0.6 → cgcsdk-1.0.9}/cgc/commands/auth/auth_utils.py +6 -5
  10. {cgcsdk-1.0.6 → cgcsdk-1.0.9}/cgc/commands/cgc_cmd.py +28 -3
  11. {cgcsdk-1.0.6 → cgcsdk-1.0.9}/cgc/commands/cgc_cmd_responses.py +8 -0
  12. cgcsdk-1.0.9/cgc/commands/cgc_models.py +9 -0
  13. {cgcsdk-1.0.6 → cgcsdk-1.0.9}/cgc/commands/compute/compute_models.py +3 -23
  14. {cgcsdk-1.0.6 → cgcsdk-1.0.9}/cgc/commands/compute/compute_utills.py +16 -6
  15. {cgcsdk-1.0.6 → cgcsdk-1.0.9}/cgc/commands/db/db_cmd.py +7 -1
  16. cgcsdk-1.0.9/cgc/commands/db/db_models.py +37 -0
  17. cgcsdk-1.0.9/cgc/commands/exceptions.py +10 -0
  18. cgcsdk-1.0.9/cgc/commands/jobs/__init__.py +10 -0
  19. cgcsdk-1.0.9/cgc/commands/jobs/job_utils.py +180 -0
  20. cgcsdk-1.0.9/cgc/commands/jobs/jobs_cmd.py +238 -0
  21. cgcsdk-1.0.9/cgc/commands/jobs/jobs_responses.py +52 -0
  22. cgcsdk-1.0.9/cgc/commands/keys/__init__.py +5 -0
  23. cgcsdk-1.0.9/cgc/commands/keys/keys_cmd.py +176 -0
  24. cgcsdk-1.0.9/cgc/commands/keys/keys_models.py +16 -0
  25. cgcsdk-1.0.9/cgc/commands/keys/keys_responses.py +47 -0
  26. cgcsdk-1.0.9/cgc/commands/keys/keys_utils.py +79 -0
  27. {cgcsdk-1.0.6 → cgcsdk-1.0.9}/cgc/commands/resource/resource_cmd.py +2 -1
  28. {cgcsdk-1.0.6 → cgcsdk-1.0.9}/cgc/sdk/__init__.py +1 -2
  29. cgcsdk-1.0.9/cgc/sdk/job.py +147 -0
  30. {cgcsdk-1.0.6 → cgcsdk-1.0.9}/cgc/sdk/resource.py +1 -0
  31. {cgcsdk-1.0.6 → cgcsdk-1.0.9}/cgc/utils/__init__.py +8 -0
  32. {cgcsdk-1.0.6 → cgcsdk-1.0.9}/cgc/utils/config_utils.py +5 -1
  33. {cgcsdk-1.0.6 → cgcsdk-1.0.9}/cgc/utils/consts/env_consts.py +1 -1
  34. {cgcsdk-1.0.6 → cgcsdk-1.0.9}/cgc/utils/custom_exceptions.py +8 -1
  35. {cgcsdk-1.0.6 → cgcsdk-1.0.9}/cgc/utils/message_utils.py +1 -1
  36. {cgcsdk-1.0.6 → cgcsdk-1.0.9}/cgc/utils/prepare_headers.py +22 -13
  37. {cgcsdk-1.0.6 → cgcsdk-1.0.9}/cgc/utils/requests_helper.py +1 -3
  38. cgcsdk-1.0.9/cgcsdk.egg-info/PKG-INFO +66 -0
  39. {cgcsdk-1.0.6 → cgcsdk-1.0.9}/cgcsdk.egg-info/SOURCES.txt +12 -3
  40. {cgcsdk-1.0.6 → cgcsdk-1.0.9}/cgcsdk.egg-info/requires.txt +0 -2
  41. {cgcsdk-1.0.6 → cgcsdk-1.0.9}/setup.py +0 -2
  42. cgcsdk-1.0.6/PKG-INFO +0 -39
  43. cgcsdk-1.0.6/README.md +0 -3
  44. cgcsdk-1.0.6/cgc/commands/exceptions.py +0 -2
  45. cgcsdk-1.0.6/cgc/sdk/handlers.py +0 -24
  46. cgcsdk-1.0.6/cgc/sdk/mongodb.py +0 -204
  47. cgcsdk-1.0.6/cgc/sdk/redis.py +0 -91
  48. cgcsdk-1.0.6/cgcsdk.egg-info/PKG-INFO +0 -39
  49. {cgcsdk-1.0.6 → cgcsdk-1.0.9}/LICENSE +0 -0
  50. {cgcsdk-1.0.6 → cgcsdk-1.0.9}/MANIFEST.in +0 -0
  51. {cgcsdk-1.0.6 → cgcsdk-1.0.9}/cgc/__init__.py +0 -0
  52. {cgcsdk-1.0.6 → cgcsdk-1.0.9}/cgc/commands/__init__.py +0 -0
  53. {cgcsdk-1.0.6 → cgcsdk-1.0.9}/cgc/commands/billing/__init__.py +0 -0
  54. {cgcsdk-1.0.6 → cgcsdk-1.0.9}/cgc/commands/billing/billing_cmd.py +0 -0
  55. {cgcsdk-1.0.6 → cgcsdk-1.0.9}/cgc/commands/billing/billing_responses.py +0 -0
  56. {cgcsdk-1.0.6 → cgcsdk-1.0.9}/cgc/commands/billing/billing_utils.py +0 -0
  57. {cgcsdk-1.0.6 → cgcsdk-1.0.9}/cgc/commands/cgc_helpers.py +0 -0
  58. {cgcsdk-1.0.6 → cgcsdk-1.0.9}/cgc/commands/compute/__init__.py +0 -0
  59. {cgcsdk-1.0.6 → cgcsdk-1.0.9}/cgc/commands/compute/compute_cmd.py +0 -0
  60. {cgcsdk-1.0.6 → cgcsdk-1.0.9}/cgc/commands/compute/compute_responses.py +0 -0
  61. {cgcsdk-1.0.6 → cgcsdk-1.0.9}/cgc/commands/db/__init__.py +0 -0
  62. {cgcsdk-1.0.6 → cgcsdk-1.0.9}/cgc/commands/debug/__init__.py +0 -0
  63. {cgcsdk-1.0.6 → cgcsdk-1.0.9}/cgc/commands/debug/debug_cmd.py +0 -0
  64. {cgcsdk-1.0.6 → cgcsdk-1.0.9}/cgc/commands/resource/__init__.py +0 -0
  65. {cgcsdk-1.0.6 → cgcsdk-1.0.9}/cgc/commands/resource/resource_responses.py +0 -0
  66. {cgcsdk-1.0.6 → cgcsdk-1.0.9}/cgc/commands/volume/__init__.py +0 -0
  67. {cgcsdk-1.0.6 → cgcsdk-1.0.9}/cgc/commands/volume/data_model.py +0 -0
  68. {cgcsdk-1.0.6 → cgcsdk-1.0.9}/cgc/commands/volume/volume_cmd.py +0 -0
  69. {cgcsdk-1.0.6 → cgcsdk-1.0.9}/cgc/commands/volume/volume_responses.py +0 -0
  70. {cgcsdk-1.0.6 → cgcsdk-1.0.9}/cgc/commands/volume/volume_utils.py +0 -0
  71. {cgcsdk-1.0.6 → cgcsdk-1.0.9}/cgc/config.py +0 -0
  72. {cgcsdk-1.0.6 → cgcsdk-1.0.9}/cgc/sdk/exceptions.py +0 -0
  73. {cgcsdk-1.0.6 → cgcsdk-1.0.9}/cgc/sdk/postgresql.py +0 -0
  74. {cgcsdk-1.0.6 → cgcsdk-1.0.9}/cgc/server.crt +0 -0
  75. {cgcsdk-1.0.6 → cgcsdk-1.0.9}/cgc/telemetry/__init__.py +0 -0
  76. {cgcsdk-1.0.6 → cgcsdk-1.0.9}/cgc/telemetry/basic.py +0 -0
  77. {cgcsdk-1.0.6 → cgcsdk-1.0.9}/cgc/tests/__init__.py +0 -0
  78. {cgcsdk-1.0.6 → cgcsdk-1.0.9}/cgc/tests/desired_responses/test_billing_invoice.txt +0 -0
  79. {cgcsdk-1.0.6 → cgcsdk-1.0.9}/cgc/tests/desired_responses/test_billing_status.txt +0 -0
  80. {cgcsdk-1.0.6 → cgcsdk-1.0.9}/cgc/tests/desired_responses/test_billing_stop_events_compute.txt +0 -0
  81. {cgcsdk-1.0.6 → cgcsdk-1.0.9}/cgc/tests/desired_responses/test_billing_stop_events_volume.txt +0 -0
  82. {cgcsdk-1.0.6 → cgcsdk-1.0.9}/cgc/tests/desired_responses/test_compute_list.txt +0 -0
  83. {cgcsdk-1.0.6 → cgcsdk-1.0.9}/cgc/tests/desired_responses/test_compute_list_no_labels.txt +0 -0
  84. {cgcsdk-1.0.6 → cgcsdk-1.0.9}/cgc/tests/desired_responses/test_tabulate_response.txt +0 -0
  85. {cgcsdk-1.0.6 → cgcsdk-1.0.9}/cgc/tests/desired_responses/test_volume_list.txt +0 -0
  86. {cgcsdk-1.0.6 → cgcsdk-1.0.9}/cgc/tests/responses_tests.py +0 -0
  87. {cgcsdk-1.0.6 → cgcsdk-1.0.9}/cgc/utils/click_group.py +0 -0
  88. {cgcsdk-1.0.6 → cgcsdk-1.0.9}/cgc/utils/consts/__init__.py +0 -0
  89. {cgcsdk-1.0.6 → cgcsdk-1.0.9}/cgc/utils/consts/message_consts.py +0 -0
  90. {cgcsdk-1.0.6 → cgcsdk-1.0.9}/cgc/utils/cryptography/__init__.py +0 -0
  91. {cgcsdk-1.0.6 → cgcsdk-1.0.9}/cgc/utils/cryptography/aes_crypto.py +0 -0
  92. {cgcsdk-1.0.6 → cgcsdk-1.0.9}/cgc/utils/cryptography/encryption_module.py +0 -0
  93. {cgcsdk-1.0.6 → cgcsdk-1.0.9}/cgc/utils/cryptography/rsa_crypto.py +0 -0
  94. {cgcsdk-1.0.6 → cgcsdk-1.0.9}/cgc/utils/response_utils.py +0 -0
  95. {cgcsdk-1.0.6 → cgcsdk-1.0.9}/cgc/utils/update.py +0 -0
  96. {cgcsdk-1.0.6 → cgcsdk-1.0.9}/cgc/utils/version_control.py +0 -0
  97. {cgcsdk-1.0.6 → cgcsdk-1.0.9}/cgcsdk.egg-info/dependency_links.txt +0 -0
  98. {cgcsdk-1.0.6 → cgcsdk-1.0.9}/cgcsdk.egg-info/entry_points.txt +0 -0
  99. {cgcsdk-1.0.6 → cgcsdk-1.0.9}/cgcsdk.egg-info/top_level.txt +0 -0
  100. {cgcsdk-1.0.6 → cgcsdk-1.0.9}/pyproject.toml +0 -0
  101. {cgcsdk-1.0.6 → cgcsdk-1.0.9}/setup.cfg +0 -0
cgcsdk-1.0.9/PKG-INFO ADDED
@@ -0,0 +1,66 @@
1
+ Metadata-Version: 2.1
2
+ Name: cgcsdk
3
+ Version: 1.0.9
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: psycopg2-binary
34
+
35
+ # Comtegra GPU Cloud CLI Client
36
+
37
+ ## Basic info
38
+
39
+ 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.
40
+
41
+ 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.
42
+
43
+ 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.
44
+
45
+ For now, we provide the ability to spawn compute resources like:
46
+
47
+ 1. [Jupyter notebook](https://jupyter.org/) with tensorflow or pytorch installed as default
48
+ 2. [Triton inferencing server](https://docs.nvidia.com/deeplearning/triton-inference-server/) for large scale inferencing
49
+ 3. [Label studio](https://labelstud.io/) for easy management of your data annotation tasks with variety of modes
50
+ 4. [Rapids](https://rapids.ai/) suite of accelerated libraries for data processing
51
+
52
+ Notebooks are equiped with all CUDA libraries and GPU drivers which enables the usage of GPU for accelerated computations.
53
+ Apart from compute resources, we provide the database engines accessible from within your namespace:
54
+
55
+ 1. [PostgreSQL](https://www.postgresql.org/)
56
+ 2. [Weaviate](https://weaviate.io/)
57
+
58
+ More are coming!
59
+ Please follow instructions to get started.
60
+
61
+ ## More info
62
+
63
+ If you'd like to know more visit:
64
+
65
+ - [Comtegra GPU Website](https://cgc.comtegra.cloud)
66
+ - [Docs](https://docs.cgc.comtegra.cloud)
cgcsdk-1.0.9/README.md ADDED
@@ -0,0 +1,32 @@
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. [PostgreSQL](https://www.postgresql.org/)
22
+ 2. [Weaviate](https://weaviate.io/)
23
+
24
+ More are coming!
25
+ Please follow instructions to get started.
26
+
27
+ ## More info
28
+
29
+ If you'd like to know more visit:
30
+
31
+ - [Comtegra GPU Website](https://cgc.comtegra.cloud)
32
+ - [Docs](https://docs.cgc.comtegra.cloud)
@@ -6,4 +6,4 @@ CONFIG_FILE_NAME = cfg.json
6
6
  TMP_DIR = .tmp
7
7
  RELEASE = 1
8
8
  MAJOR_VERSION = 0
9
- MINOR_VERSION = 6
9
+ MINOR_VERSION = 9
@@ -1,5 +1,35 @@
1
1
  # Change Log
2
2
 
3
+ ## 1.0.9
4
+
5
+ Release on April 23, 2024
6
+
7
+ * updated cgc to work with cgc-server 1.1.0
8
+ * updated registration process
9
+ * updated available apps, so it reflects changes in cgc-server
10
+ * hotfix: listening jobs, which are not Running
11
+
12
+ ## 1.0.8
13
+
14
+ Release on April 11, 2024
15
+
16
+ * added new command group: cgc keys
17
+ * ssh create - create new ssh key, for ssh access
18
+ * ssh list - list all ssh keys
19
+ * ssh delete - delete ssh key
20
+ * ssh update - update ssh key
21
+
22
+ ## 1.0.7
23
+
24
+ Release on April 04, 2024
25
+
26
+ * speed of resource creation with volumes / shared memory, has been improved
27
+ * added jobs creation: cgc job create
28
+ * added jobs list: cgc job list
29
+ * added jobs delete: cgc job delete
30
+ * added logs (STDOUT, STDERR) reader for spawned applications: cgc logs
31
+ * added SDK for logs & jobs
32
+
3
33
  ## 1.0.6
4
34
 
5
35
  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,13 @@ 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
+ from cgc.commands.keys.keys_cmd import keys_group
23
+
20
24
  from cgc.utils.version_control import check_version, _get_version
21
25
  from cgc.utils.click_group import CustomGroup
22
26
 
@@ -41,7 +45,9 @@ cli.add_command(resource_group)
41
45
  cli.add_command(billing_group)
42
46
  cli.add_command(cgc_status)
43
47
  cli.add_command(sending_telemetry_permission)
44
-
48
+ cli.add_command(cgc_logs)
49
+ cli.add_command(job_group)
50
+ cli.add_command(keys_group)
45
51
 
46
52
  if __name__ == "__main__" or __name__ == "cgc.cgc":
47
53
  cli()
@@ -7,9 +7,9 @@ class AuthCommandException(ResponseException):
7
7
 
8
8
  class NoNamespaceInConfig(AuthCommandException):
9
9
  def __init__(self) -> None:
10
- super().__init__(f"Namespace not readable from config file.")
10
+ super().__init__("Namespace not readable from config file.")
11
11
 
12
12
 
13
13
  class NoConfigFileFound(AuthCommandException):
14
14
  def __init__(self) -> None:
15
- super().__init__(f"Config does not exists.")
15
+ super().__init__("Config does not exists.")
@@ -9,7 +9,11 @@ from cgc.commands.auth.auth_utils import (
9
9
  auth_delete_api_key,
10
10
  auth_list_api_keys,
11
11
  )
12
- from cgc.utils.prepare_headers import get_url_and_prepare_headers_register
12
+ from cgc.utils.prepare_headers import (
13
+ get_url_and_prepare_headers_register,
14
+ load_user_api_url,
15
+ load_user_cgc_secret,
16
+ )
13
17
  from cgc.utils.cryptography import rsa_crypto
14
18
  from cgc.utils.click_group import CustomCommand, CustomGroup
15
19
  from cgc.utils.requests_helper import call_api, EndpointTypes
@@ -20,6 +24,7 @@ from cgc.utils.response_utils import (
20
24
  )
21
25
  from cgc.utils import (
22
26
  check_if_config_exist,
27
+ require_answer_loop,
23
28
  require_confirm_loop,
24
29
  find_first_available_config_name,
25
30
  )
@@ -55,9 +60,14 @@ def auth_register(config_filename: str = "cfg.json"):
55
60
  require_confirm_loop("Do you want to add new context?")
56
61
  config_filename = find_first_available_config_name()
57
62
 
63
+ cgc_api_url = require_answer_loop("Enter CGC server address", load_user_api_url())
64
+ cgc_secret = require_answer_loop("Enter CGC secret", load_user_cgc_secret())
65
+
58
66
  user_id = input("User ID: ")
59
67
  access_key = input("Access key: ")
60
- url, headers = get_url_and_prepare_headers_register(user_id, access_key)
68
+ url, headers = get_url_and_prepare_headers_register(
69
+ user_id, access_key, cgc_api_url, cgc_secret
70
+ )
61
71
  metric = "auth.register"
62
72
  pub_key_bytes, priv_key_bytes = rsa_crypto.key_generate_pair()
63
73
  __payload = pub_key_bytes
@@ -74,6 +84,8 @@ def auth_register(config_filename: str = "cfg.json"):
74
84
  user_id,
75
85
  priv_key_bytes,
76
86
  config_filename,
87
+ cgc_api_url,
88
+ cgc_secret,
77
89
  )
78
90
  )
79
91
 
@@ -8,14 +8,21 @@ from cgc.utils.message_utils import key_error_decorator_for_helpers
8
8
 
9
9
 
10
10
  @key_error_decorator_for_helpers
11
- def auth_register_response(response, user_id, priv_key_bytes, config_filename) -> str:
11
+ def auth_register_response(
12
+ response, user_id, priv_key_bytes, config_filename, cgc_api_url, cgc_secret
13
+ ) -> str:
12
14
  TMP_DIR_PATH = os.path.join(get_config_path(), TMP_DIR)
13
15
  unzip_dir, namespace = auth_utils.save_and_unzip_file(response)
14
16
  aes_key, password = auth_utils.get_aes_key_and_password(unzip_dir, priv_key_bytes)
15
17
 
16
18
  os.environ["CONFIG_FILE_NAME"] = config_filename
17
19
  save_to_config(
18
- user_id=user_id, password=password, aes_key=aes_key, namespace=namespace
20
+ user_id=user_id,
21
+ password=password,
22
+ aes_key=aes_key,
23
+ namespace=namespace,
24
+ cgc_api_url=cgc_api_url,
25
+ cgc_secret=cgc_secret,
19
26
  )
20
27
  auth_utils.auth_create_api_key_with_save()
21
28
  shutil.rmtree(TMP_DIR_PATH)
@@ -10,7 +10,7 @@ from cgc.utils.config_utils import save_to_config
10
10
  from cgc.utils.config_utils import read_from_cfg
11
11
  from cgc.utils.cryptography import rsa_crypto
12
12
  from cgc.utils import prepare_headers
13
- from cgc.utils.consts.env_consts import API_URL, TMP_DIR
13
+ from cgc.utils.consts.env_consts import TMP_DIR
14
14
 
15
15
  from cgc.utils.requests_helper import call_api, EndpointTypes
16
16
  from cgc.utils.response_utils import retrieve_and_validate_response_send_metric
@@ -29,9 +29,10 @@ def _get_jwt_from_server(user_id: str = None, password: str = None) -> str:
29
29
  if user_id is None or password is None:
30
30
  if user_id is not None or password is not None:
31
31
  raise ValueError("Both user_id and password must be provided")
32
+ if user_id is None and password is None:
32
33
  user_id = urllib.parse.quote(read_from_cfg("user_id"))
33
34
  password = urllib.parse.quote(read_from_cfg("password"))
34
- url = f"{API_URL}/v1/api/user/create/token"
35
+ url = f"{prepare_headers.load_user_api_url()}/v1/api/user/create/token"
35
36
  headers = {
36
37
  "accept": "application/json",
37
38
  "Content-Type": "application/x-www-form-urlencoded",
@@ -54,7 +55,7 @@ def get_jwt(user_id: str = None, password: str = None) -> str:
54
55
 
55
56
  def auth_create_api_key_with_save(user_id: str = None, password: str = None):
56
57
  """Function to create API key and API secret for user and save it to config file."""
57
- url = f"{API_URL}/v1/api/user/create/api-key"
58
+ url = f"{prepare_headers.load_user_api_url()}/v1/api/user/create/api-key"
58
59
  headers = prepare_headers.prepare_headers_api_key(user_id, password)
59
60
  metric = "auth.api-key"
60
61
  __res = call_api(
@@ -74,7 +75,7 @@ def auth_create_api_key_with_save(user_id: str = None, password: str = None):
74
75
 
75
76
  def auth_delete_api_key(api_key: str, user_id: str = None, password: str = None):
76
77
  """Function to delete API key."""
77
- url = f"{API_URL}/v1/api/user/delete/api-key?api_key={api_key}"
78
+ url = f"{prepare_headers.load_user_api_url()}/v1/api/user/delete/api-key?api_key={api_key}"
78
79
  headers = prepare_headers.prepare_headers_api_key(user_id, password)
79
80
  metric = "auth.api-key"
80
81
  __res = call_api(
@@ -89,7 +90,7 @@ def auth_delete_api_key(api_key: str, user_id: str = None, password: str = None)
89
90
 
90
91
  def auth_list_api_keys(user_id: str = None, password: str = None):
91
92
  """Function to list API keys."""
92
- url = f"{API_URL}/v1/api/user/list/api-key"
93
+ url = f"{prepare_headers.load_user_api_url()}/v1/api/user/list/api-key"
93
94
  headers = prepare_headers.prepare_headers_api_key(user_id, password)
94
95
  metric = "auth.api-key"
95
96
  __res = call_api(
@@ -1,7 +1,10 @@
1
1
  import click
2
2
  import json
3
3
 
4
- from cgc.commands.cgc_cmd_responses import cgc_status_response
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('utf-8'),
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
+ )
@@ -0,0 +1,9 @@
1
+ from enum import Enum
2
+
3
+
4
+ class CGCEntityList(Enum):
5
+ """Base class for other lists"""
6
+
7
+ @classmethod
8
+ def get_list(cls) -> list[str]:
9
+ return [el.value for el in cls]
@@ -1,12 +1,4 @@
1
- from enum import Enum
2
-
3
-
4
- class CGCEntityList(Enum):
5
- """Base class for other lists"""
6
-
7
- @classmethod
8
- def get_list(cls) -> list[str]:
9
- return [el.value for el in cls]
1
+ from cgc.commands.cgc_models import CGCEntityList
10
2
 
11
3
 
12
4
  class ComputesList(CGCEntityList):
@@ -29,20 +21,6 @@ class ComputesList(CGCEntityList):
29
21
  CUSTOM = "custom"
30
22
 
31
23
 
32
- class DatabasesList(CGCEntityList):
33
- """List of templates in cgc-server
34
-
35
- :param Enum: name of template
36
- :type Enum: str
37
- """
38
-
39
- MONGODB = "mongodb"
40
- POSTGRESQL = "postgresql"
41
- REDIS = "redis"
42
- WEAVIATE = "weaviate"
43
- # MINIO = "minio"
44
-
45
-
46
24
  class GPUsList(CGCEntityList):
47
25
  """List of templates in cgc-server
48
26
 
@@ -54,3 +32,5 @@ class GPUsList(CGCEntityList):
54
32
  A100 = "A100"
55
33
  A5000 = "A5000"
56
34
  H100 = "H100"
35
+ P40 = "P40"
36
+ P100 = "P100"
@@ -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
- def get_app_mounts(pod_list:list) -> list:
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 = [x for x in pod["containers"] if x["name"] == main_container_name][0]
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("Parser was unable to find main container in server output in container list")
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"])
@@ -2,9 +2,10 @@ import json
2
2
  import click
3
3
 
4
4
  from cgc.commands.compute.compute_responses import compute_list_response
5
- from cgc.commands.compute.compute_models import DatabasesList
5
+ from cgc.commands.db.db_models import DatabasesList
6
6
  from cgc.commands.compute.compute_responses import compute_create_response
7
7
  from cgc.commands.compute.compute_utills import compute_create_payload
8
+ from cgc.commands.exceptions import DatabaseCreationException
8
9
  from cgc.commands.resource.resource_cmd import resource_delete
9
10
  from cgc.utils.prepare_headers import get_api_url_and_prepare_headers
10
11
  from cgc.utils.response_utils import retrieve_and_validate_response_send_metric
@@ -66,6 +67,11 @@ def db_create(
66
67
  :param name: name of app
67
68
  :type name: str
68
69
  """
70
+ try:
71
+ DatabasesList.verify(entity)
72
+ except DatabaseCreationException as e:
73
+ click.echo(e, err=True, color="yellow")
74
+ return
69
75
  api_url, headers = get_api_url_and_prepare_headers()
70
76
  url = f"{api_url}/v1/api/resource/create"
71
77
  metric = "db.create"
@@ -0,0 +1,37 @@
1
+ from cgc.commands.cgc_models import CGCEntityList
2
+ from cgc.commands.exceptions import DatabaseCreationException
3
+
4
+
5
+ class DatabasesList(CGCEntityList):
6
+ """List of templates in cgc-server
7
+
8
+ :param Enum: name of template
9
+ :type Enum: str
10
+ """
11
+
12
+ POSTGRESQL = "postgresql"
13
+ WEAVIATE = "weaviate"
14
+ # MINIO = "minio"
15
+ MONGODB = "mongodb"
16
+ REDIS = "redis"
17
+
18
+ @staticmethod
19
+ def verify(entity: str) -> str:
20
+ if entity == "mongodb":
21
+ raise DatabaseCreationException(
22
+ """
23
+ Due to license agreement we can not serve MongoDB as a single click app.
24
+ If you like to use it you can spawn one as custom image.
25
+
26
+ cgc compute create custom -n name -c 4 -m 8 --image mongo
27
+ """
28
+ )
29
+ elif entity == "redis":
30
+ raise DatabaseCreationException(
31
+ """
32
+ Due to license agreement we can not serve Redis as a single click app.
33
+ If you like to use it you can spawn one as custom image.
34
+
35
+ cgc compute create custom -n name -c 4 -m 8 --image redis
36
+ """
37
+ )
@@ -0,0 +1,10 @@
1
+ class ResponseException(Exception):
2
+ pass
3
+
4
+
5
+ class InternalException(Exception):
6
+ pass
7
+
8
+
9
+ class DatabaseCreationException(InternalException):
10
+ pass
@@ -0,0 +1,10 @@
1
+ from cgc.commands.exceptions import ResponseException
2
+
3
+
4
+ class JobCommandException(ResponseException):
5
+ pass
6
+
7
+
8
+ class NoJobsToList(JobCommandException):
9
+ def __init__(self) -> None:
10
+ super().__init__("No jobs to list.")