zipher-sdk 0.2.0__tar.gz → 0.3.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 (33) hide show
  1. zipher-sdk-0.3.9/PKG-INFO +205 -0
  2. zipher-sdk-0.3.9/README.md +189 -0
  3. {zipher-sdk-0.2.0 → zipher-sdk-0.3.9}/setup.py +9 -4
  4. zipher-sdk-0.3.9/tests/test_acl/__init__.py +0 -0
  5. zipher-sdk-0.3.9/tests/test_acl/sample_job.py +15 -0
  6. zipher-sdk-0.3.9/tests/test_acl/test_acl.py +353 -0
  7. {zipher-sdk-0.2.0 → zipher-sdk-0.3.9}/tests/test_client.py +3 -0
  8. zipher-sdk-0.3.9/zipher/__init__.py +2 -0
  9. zipher-sdk-0.3.9/zipher/acl/__init__.py +0 -0
  10. zipher-sdk-0.3.9/zipher/acl/models.py +49 -0
  11. zipher-sdk-0.3.9/zipher/acl/zipher_installer.py +376 -0
  12. zipher-sdk-0.3.9/zipher/cli.py +153 -0
  13. {zipher-sdk-0.2.0 → zipher-sdk-0.3.9}/zipher/client.py +30 -12
  14. zipher-sdk-0.3.9/zipher/exceptions.py +16 -0
  15. zipher-sdk-0.3.9/zipher/models.py +33 -0
  16. zipher-sdk-0.3.9/zipher/utils.py +67 -0
  17. zipher-sdk-0.3.9/zipher_sdk.egg-info/PKG-INFO +205 -0
  18. {zipher-sdk-0.2.0 → zipher-sdk-0.3.9}/zipher_sdk.egg-info/SOURCES.txt +9 -1
  19. zipher-sdk-0.3.9/zipher_sdk.egg-info/entry_points.txt +3 -0
  20. zipher-sdk-0.3.9/zipher_sdk.egg-info/requires.txt +3 -0
  21. zipher-sdk-0.2.0/PKG-INFO +0 -75
  22. zipher-sdk-0.2.0/README.md +0 -58
  23. zipher-sdk-0.2.0/zipher/__init__.py +0 -1
  24. zipher-sdk-0.2.0/zipher/conf.py +0 -6
  25. zipher-sdk-0.2.0/zipher/exceptions.py +0 -4
  26. zipher-sdk-0.2.0/zipher/models.py +0 -8
  27. zipher-sdk-0.2.0/zipher_sdk.egg-info/PKG-INFO +0 -75
  28. zipher-sdk-0.2.0/zipher_sdk.egg-info/requires.txt +0 -3
  29. {zipher-sdk-0.2.0 → zipher-sdk-0.3.9}/LICENSE +0 -0
  30. {zipher-sdk-0.2.0 → zipher-sdk-0.3.9}/setup.cfg +0 -0
  31. {zipher-sdk-0.2.0 → zipher-sdk-0.3.9}/tests/__init__.py +0 -0
  32. {zipher-sdk-0.2.0 → zipher-sdk-0.3.9}/zipher_sdk.egg-info/dependency_links.txt +0 -0
  33. {zipher-sdk-0.2.0 → zipher-sdk-0.3.9}/zipher_sdk.egg-info/top_level.txt +0 -0
@@ -0,0 +1,205 @@
1
+ Metadata-Version: 2.1
2
+ Name: zipher-sdk
3
+ Version: 0.3.9
4
+ Summary: Python SDK for programmatic access to the Zipher API
5
+ Home-page: UNKNOWN
6
+ Author: Zipher Inc.
7
+ Author-email: yoav@zipher.cloud
8
+ License: UNKNOWN
9
+ Platform: UNKNOWN
10
+ Classifier: Programming Language :: Python :: 3
11
+ Classifier: License :: OSI Approved :: MIT License
12
+ Classifier: Operating System :: OS Independent
13
+ Description-Content-Type: text/markdown
14
+ License-File: LICENSE
15
+
16
+
17
+ # Zipher SDK
18
+
19
+ The Zipher SDK is a Python library for interacting with Zipher's APIs.
20
+
21
+ - [Package Installation](#package-installation)
22
+ - [Granting access to Zipher](#providing-zipher-with-access-to-databricks-workspace)
23
+ - [Usage](#sdk-usage)
24
+
25
+ ## Package Installation
26
+
27
+ You can install the Zipher SDK using pip:
28
+
29
+ ```bash
30
+ pip install zipher-sdk
31
+ ```
32
+
33
+ ## Providing Zipher with access to Databricks workspace
34
+
35
+ After installing `zipher-sdk` package a cli tool to automatically create all necessary resources for Zipher is available.
36
+
37
+ ### Setting up credentials
38
+
39
+ You need to provide credentials that will be used to create all necessary resources and permissions for Zipher.
40
+
41
+ Here are ways to set up credentials:
42
+ * `.databrickscfg` config (cli tool supports profile choice as an argument)
43
+ * `ZIPHER_DATABRICKS_HOST` and `ZIPHER_DATABRICKS_TOKEN` or `ZIPHER_DATABRICKS_CLIENT_ID`, `ZIPHER_DATABRICKS_CLIENT_SECRET` environment variables
44
+ * providing credentials as arguments to cli tool
45
+
46
+ ### Cli tool usage examples
47
+
48
+ #### Providing Zipher with access to a list of jobs
49
+ ```
50
+ zipher setup --jobs-list 12345678,87654321,12344321,21436587
51
+ ```
52
+
53
+ #### Providing Zipher with access to n jobs from the workspace
54
+ ```
55
+ zipher setup --max-jobs 50
56
+ ```
57
+
58
+ #### Providing Zipher with readonly access to a list of jobs
59
+ ```
60
+ zipher setup --readonly --jobs-list 12345678,87654321,12344321,21436587
61
+ ```
62
+
63
+ ### Full cli tool specification
64
+ ```
65
+ usage: zipher setup [-h] [--workspace-host WORKSPACE_HOST] [--access-token ACCESS_TOKEN] [--client-id CLIENT_ID] [--client-secret CLIENT_SECRET] [--profile PROFILE] [--verbose] [--jobs-list JOBS_LIST] [--max-jobs MAX_JOBS]
66
+ [--max-runs MAX_RUNS] [--days-back DAYS_BACK] [--readonly] [--pat] [--skip-approval]
67
+
68
+ options:
69
+ -h, --help show this help message and exit
70
+ --workspace-host WORKSPACE_HOST
71
+ Databricks workspace host URL.
72
+ --access-token ACCESS_TOKEN
73
+ Databricks workspace access token.
74
+ --client-id CLIENT_ID
75
+ Databricks workspace OAuth client id.
76
+ --client-secret CLIENT_SECRET
77
+ Databricks workspace OAuth client secret.
78
+ --profile PROFILE Profile name from .databrickscfg.
79
+ --verbose Print full error message on fail.
80
+ --jobs-list JOBS_LIST
81
+ Comma-separated list of jobs ids to provide access to.
82
+ --max-jobs MAX_JOBS Maximum number of jobs to consider when iterating over jobs to grant permissions (default: 2000).
83
+ --max-runs MAX_RUNS Maximum number of runs to consider when iterating over runs to grant permissions to relative jobs (default: 2000).
84
+ --days-back DAYS_BACK
85
+ How many days back to fetch relevant job runs for permission updates (default: 7).
86
+ --readonly Provide Zipher with only CAN_VIEW permissions on listed jobs. When not provided will default to CAN_MANAGE permissions.
87
+ --pat Generate Personal Access Token for Zipher instead of default OAuth client creds.
88
+ --skip-approval Skip user input approval.
89
+
90
+ ```
91
+
92
+
93
+ ## SDK Usage
94
+
95
+ Here are some basic examples of how you can use the Zipher SDK to optimize your databricks clusters using Zipher's ML-powered optimization engine:
96
+
97
+ ### Update Existing Configuration
98
+
99
+ You can update an existing configuration by initializing a zipher Client and sending a JSON payload to the `update_existing_conf` function. Here's how you can do it:
100
+
101
+ ```python
102
+ from zipher import Client
103
+
104
+ client = Client(customer_id="my_customer_id") # assuming the zipher API key is stored in ZIPHER_API_KEY environment variable
105
+
106
+ # Your existing cluster config:
107
+ config_payload = {
108
+ "new_cluster": {
109
+ "autoscale": {
110
+ "min_workers": 1,
111
+ "max_workers": 30
112
+ },
113
+ "cluster_name": "my-cluster",
114
+ "spark_version": "10.4.x-scala2.12",
115
+ "spark_conf": {
116
+ "spark.driver.maxResultSize": "4g"
117
+ },
118
+ "aws_attributes": {
119
+ "first_on_demand": 0,
120
+ "availability": "SPOT",
121
+ "zone_id": "auto",
122
+ "spot_bid_price_percent": 100,
123
+ "ebs_volume_count": 0
124
+ },
125
+ "node_type_id": "rd-fleet.2xlarge",
126
+ "driver_node_type_id": "rd-fleet.xlarge",
127
+ "spark_env_vars": {},
128
+ "enable_elastic_disk": "false"
129
+ }
130
+ }
131
+
132
+ # Update configuration
133
+ optimized_cluster = client.update_existing_conf(job_id="my-job-id", existing_conf=config_payload)
134
+
135
+ # Continue with sending the optimized configuration to Databricks via the Databricks python SDK, Airflow operator, etc.
136
+
137
+ ```
138
+
139
+ ### Update Existing Multiple Tasks Configuration
140
+
141
+ You can update multiple databricks tasks by initializing a zipher Client and sending a JSON representing a list of dbx SubmitTask objects to
142
+ the `get_optimized_tasks` function.
143
+
144
+ ```python
145
+ from zipher import Client
146
+
147
+ client = Client(customer_id="my_customer_id") # assuming the zipher API key is stored in ZIPHER_API_KEY environment variable
148
+
149
+ tasks_to_optimize = [
150
+ {
151
+ "task_key": "task_1",
152
+ "description": "Test notebook task",
153
+ "notebook_task": {
154
+ "notebook_path": "/path/to/your/notebook",
155
+ "base_parameters": {
156
+ "param1": "value1"
157
+ }
158
+ },
159
+ "new_cluster": {
160
+ "spark_version": "14.3.x-scala2.12",
161
+ "node_type_id": "m6id.large",
162
+ "driver_node_type_id": "m6id.large",
163
+ "num_workers": 2,
164
+ "aws_attributes": {
165
+ "first_on_demand": 0,
166
+ "availability": "SPOT",
167
+ "zone_id": "auto",
168
+ "spot_bid_price_percent": 100,
169
+ "ebs_volume_count": 0
170
+ },
171
+ "spark_conf": {
172
+ "spark.driver.maxResultSize": "4g"
173
+ }
174
+ }
175
+ },
176
+ {
177
+ "task_key": "task_2",
178
+ "description": "Test Python task",
179
+ "spark_python_task": {
180
+ "python_file": "/path/to/your/python_file.py",
181
+ },
182
+ "new_cluster": {
183
+ "spark_version": "14.3.x-scala2.12",
184
+ "node_type_id": "m6id.large",
185
+ "driver_node_type_id": "m6id.large",
186
+ "num_workers": 2,
187
+ "spark_conf": {
188
+ "spark.driver.maxResultSize": "4g"
189
+ }
190
+ },
191
+ "timeout_seconds": 3600,
192
+ "depends_on": [
193
+ {
194
+ "task_key": "task_1"
195
+ }
196
+ ]
197
+ }
198
+ ]
199
+
200
+ # Update tasks
201
+ optimized_tasks = client.get_optimized_tasks(job_id="my-job-id", tasks=tasks_to_optimize)
202
+
203
+ # Continue with sending the optimized tasks to Databricks via the Databricks python SDK, Airflow operator, etc.
204
+ ```
205
+
@@ -0,0 +1,189 @@
1
+
2
+ # Zipher SDK
3
+
4
+ The Zipher SDK is a Python library for interacting with Zipher's APIs.
5
+
6
+ - [Package Installation](#package-installation)
7
+ - [Granting access to Zipher](#providing-zipher-with-access-to-databricks-workspace)
8
+ - [Usage](#sdk-usage)
9
+
10
+ ## Package Installation
11
+
12
+ You can install the Zipher SDK using pip:
13
+
14
+ ```bash
15
+ pip install zipher-sdk
16
+ ```
17
+
18
+ ## Providing Zipher with access to Databricks workspace
19
+
20
+ After installing `zipher-sdk` package a cli tool to automatically create all necessary resources for Zipher is available.
21
+
22
+ ### Setting up credentials
23
+
24
+ You need to provide credentials that will be used to create all necessary resources and permissions for Zipher.
25
+
26
+ Here are ways to set up credentials:
27
+ * `.databrickscfg` config (cli tool supports profile choice as an argument)
28
+ * `ZIPHER_DATABRICKS_HOST` and `ZIPHER_DATABRICKS_TOKEN` or `ZIPHER_DATABRICKS_CLIENT_ID`, `ZIPHER_DATABRICKS_CLIENT_SECRET` environment variables
29
+ * providing credentials as arguments to cli tool
30
+
31
+ ### Cli tool usage examples
32
+
33
+ #### Providing Zipher with access to a list of jobs
34
+ ```
35
+ zipher setup --jobs-list 12345678,87654321,12344321,21436587
36
+ ```
37
+
38
+ #### Providing Zipher with access to n jobs from the workspace
39
+ ```
40
+ zipher setup --max-jobs 50
41
+ ```
42
+
43
+ #### Providing Zipher with readonly access to a list of jobs
44
+ ```
45
+ zipher setup --readonly --jobs-list 12345678,87654321,12344321,21436587
46
+ ```
47
+
48
+ ### Full cli tool specification
49
+ ```
50
+ usage: zipher setup [-h] [--workspace-host WORKSPACE_HOST] [--access-token ACCESS_TOKEN] [--client-id CLIENT_ID] [--client-secret CLIENT_SECRET] [--profile PROFILE] [--verbose] [--jobs-list JOBS_LIST] [--max-jobs MAX_JOBS]
51
+ [--max-runs MAX_RUNS] [--days-back DAYS_BACK] [--readonly] [--pat] [--skip-approval]
52
+
53
+ options:
54
+ -h, --help show this help message and exit
55
+ --workspace-host WORKSPACE_HOST
56
+ Databricks workspace host URL.
57
+ --access-token ACCESS_TOKEN
58
+ Databricks workspace access token.
59
+ --client-id CLIENT_ID
60
+ Databricks workspace OAuth client id.
61
+ --client-secret CLIENT_SECRET
62
+ Databricks workspace OAuth client secret.
63
+ --profile PROFILE Profile name from .databrickscfg.
64
+ --verbose Print full error message on fail.
65
+ --jobs-list JOBS_LIST
66
+ Comma-separated list of jobs ids to provide access to.
67
+ --max-jobs MAX_JOBS Maximum number of jobs to consider when iterating over jobs to grant permissions (default: 2000).
68
+ --max-runs MAX_RUNS Maximum number of runs to consider when iterating over runs to grant permissions to relative jobs (default: 2000).
69
+ --days-back DAYS_BACK
70
+ How many days back to fetch relevant job runs for permission updates (default: 7).
71
+ --readonly Provide Zipher with only CAN_VIEW permissions on listed jobs. When not provided will default to CAN_MANAGE permissions.
72
+ --pat Generate Personal Access Token for Zipher instead of default OAuth client creds.
73
+ --skip-approval Skip user input approval.
74
+
75
+ ```
76
+
77
+
78
+ ## SDK Usage
79
+
80
+ Here are some basic examples of how you can use the Zipher SDK to optimize your databricks clusters using Zipher's ML-powered optimization engine:
81
+
82
+ ### Update Existing Configuration
83
+
84
+ You can update an existing configuration by initializing a zipher Client and sending a JSON payload to the `update_existing_conf` function. Here's how you can do it:
85
+
86
+ ```python
87
+ from zipher import Client
88
+
89
+ client = Client(customer_id="my_customer_id") # assuming the zipher API key is stored in ZIPHER_API_KEY environment variable
90
+
91
+ # Your existing cluster config:
92
+ config_payload = {
93
+ "new_cluster": {
94
+ "autoscale": {
95
+ "min_workers": 1,
96
+ "max_workers": 30
97
+ },
98
+ "cluster_name": "my-cluster",
99
+ "spark_version": "10.4.x-scala2.12",
100
+ "spark_conf": {
101
+ "spark.driver.maxResultSize": "4g"
102
+ },
103
+ "aws_attributes": {
104
+ "first_on_demand": 0,
105
+ "availability": "SPOT",
106
+ "zone_id": "auto",
107
+ "spot_bid_price_percent": 100,
108
+ "ebs_volume_count": 0
109
+ },
110
+ "node_type_id": "rd-fleet.2xlarge",
111
+ "driver_node_type_id": "rd-fleet.xlarge",
112
+ "spark_env_vars": {},
113
+ "enable_elastic_disk": "false"
114
+ }
115
+ }
116
+
117
+ # Update configuration
118
+ optimized_cluster = client.update_existing_conf(job_id="my-job-id", existing_conf=config_payload)
119
+
120
+ # Continue with sending the optimized configuration to Databricks via the Databricks python SDK, Airflow operator, etc.
121
+
122
+ ```
123
+
124
+ ### Update Existing Multiple Tasks Configuration
125
+
126
+ You can update multiple databricks tasks by initializing a zipher Client and sending a JSON representing a list of dbx SubmitTask objects to
127
+ the `get_optimized_tasks` function.
128
+
129
+ ```python
130
+ from zipher import Client
131
+
132
+ client = Client(customer_id="my_customer_id") # assuming the zipher API key is stored in ZIPHER_API_KEY environment variable
133
+
134
+ tasks_to_optimize = [
135
+ {
136
+ "task_key": "task_1",
137
+ "description": "Test notebook task",
138
+ "notebook_task": {
139
+ "notebook_path": "/path/to/your/notebook",
140
+ "base_parameters": {
141
+ "param1": "value1"
142
+ }
143
+ },
144
+ "new_cluster": {
145
+ "spark_version": "14.3.x-scala2.12",
146
+ "node_type_id": "m6id.large",
147
+ "driver_node_type_id": "m6id.large",
148
+ "num_workers": 2,
149
+ "aws_attributes": {
150
+ "first_on_demand": 0,
151
+ "availability": "SPOT",
152
+ "zone_id": "auto",
153
+ "spot_bid_price_percent": 100,
154
+ "ebs_volume_count": 0
155
+ },
156
+ "spark_conf": {
157
+ "spark.driver.maxResultSize": "4g"
158
+ }
159
+ }
160
+ },
161
+ {
162
+ "task_key": "task_2",
163
+ "description": "Test Python task",
164
+ "spark_python_task": {
165
+ "python_file": "/path/to/your/python_file.py",
166
+ },
167
+ "new_cluster": {
168
+ "spark_version": "14.3.x-scala2.12",
169
+ "node_type_id": "m6id.large",
170
+ "driver_node_type_id": "m6id.large",
171
+ "num_workers": 2,
172
+ "spark_conf": {
173
+ "spark.driver.maxResultSize": "4g"
174
+ }
175
+ },
176
+ "timeout_seconds": 3600,
177
+ "depends_on": [
178
+ {
179
+ "task_key": "task_1"
180
+ }
181
+ ]
182
+ }
183
+ ]
184
+
185
+ # Update tasks
186
+ optimized_tasks = client.get_optimized_tasks(job_id="my-job-id", tasks=tasks_to_optimize)
187
+
188
+ # Continue with sending the optimized tasks to Databricks via the Databricks python SDK, Airflow operator, etc.
189
+ ```
@@ -8,7 +8,7 @@ with open('README.md', encoding='utf-8') as f:
8
8
 
9
9
  setup(
10
10
  name='zipher-sdk',
11
- version='0.2.0',
11
+ version='0.3.9',
12
12
  description='Python SDK for programmatic access to the Zipher API',
13
13
  long_description=long_description,
14
14
  long_description_content_type='text/markdown',
@@ -16,10 +16,15 @@ setup(
16
16
  author_email='yoav@zipher.cloud',
17
17
  packages=find_packages(),
18
18
  install_requires=[
19
- "pydantic==2.1.1",
20
- "requests==2.31.0",
21
- "databricks-sdk==0.28.0"
19
+ "pydantic>=2.7.3,<3.0.0",
20
+ "requests==2.32.3",
21
+ "databricks-sdk==0.52.0"
22
22
  ],
23
+ entry_points={
24
+ "console_scripts": [
25
+ "zipher=zipher.cli:main",
26
+ ]
27
+ },
23
28
  classifiers=[
24
29
  'Programming Language :: Python :: 3',
25
30
  'License :: OSI Approved :: MIT License',
File without changes
@@ -0,0 +1,15 @@
1
+ import os
2
+ from time import sleep
3
+
4
+ print("<<<<<<<< >>>>>>>>> HELLO WORLD <<<<<<<< >>>>>>>>>")
5
+ sleep_time = 20
6
+
7
+ sample_secret_env_var = os.getenv('ZIPHER_API_KEY')
8
+ if sample_secret_env_var and sample_secret_env_var == 'test_key':
9
+ print(f"Successfully retrieved secret from environment variable: {sample_secret_env_var}")
10
+ sleep_time = 90
11
+
12
+
13
+ print(f"About to sleep for {sleep_time} seconds")
14
+ sleep(sleep_time)
15
+ print("<<<<<<<< >>>>>>>>> GOODBYE WORLD <<<<<<<< >>>>>>>>>")