Skip to content

Commit ed81ffe

Browse files
authored
[PROD-1293] Add 'auto_appy_recs' property to projects (#51)
1 parent e43d10b commit ed81ffe

File tree

3 files changed

+28
-2
lines changed

3 files changed

+28
-2
lines changed

sync/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
"""Library for leveraging the power of Sync"""
2-
__version__ = "0.4.4"
2+
__version__ = "0.4.5"
33

44
TIME_FORMAT = "%Y-%m-%dT%H:%M:%SZ"

sync/api/projects.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ def create_project(
5555
job_id: str = None,
5656
cluster_log_url: str = None,
5757
prediction_preference: Preference = Preference.ECONOMY,
58+
auto_apply_recs: bool = False,
5859
prediction_params: dict = None,
5960
app_id: str = None,
6061
) -> Response[dict]:
@@ -72,6 +73,8 @@ def create_project(
7273
:type cluster_log_url: str, optional
7374
:param prediction_preference: preferred prediction solution, defaults to `Preference.ECONOMY`
7475
:type prediction_preference: Preference, optional
76+
:param auto_apply_recs: automatically apply project recommendations, defaults to False
77+
:type auto_apply_recs: bool, optional
7578
:param prediction_params: dictionary of prediction parameters, defaults to None. Valid options are documented `here <https://developers.synccomputing.com/reference/create_project_v1_projects_post>`__
7679
:type prediction_params: dict, optional
7780
:param app_id: Apache Spark application identifier, defaults to None
@@ -88,6 +91,7 @@ def create_project(
8891
"job_id": job_id,
8992
"cluster_log_url": cluster_log_url,
9093
"prediction_preference": prediction_preference,
94+
"auto_apply_recs": auto_apply_recs,
9195
"prediction_params": prediction_params,
9296
"app_id": app_id,
9397
}
@@ -112,6 +116,7 @@ def update_project(
112116
cluster_log_url: str = None,
113117
app_id: str = None,
114118
prediction_preference: Preference = None,
119+
auto_apply_recs: bool = None,
115120
prediction_params: dict = None,
116121
) -> Response[dict]:
117122
"""Updates a project's mutable properties
@@ -126,6 +131,8 @@ def update_project(
126131
:type app_id: str, optional
127132
:param prediction_preference: default preference for predictions, defaults to None
128133
:type prediction_preference: Preference, optional
134+
:param auto_apply_recs: automatically apply project recommendations, defaults to None
135+
:type auto_apply_recs: bool, optional
129136
:param prediction_params: dictionary of prediction parameters, defaults to None. Valid options are documented `here <https://developers.synccomputing.com/reference/update_project_v1_projects__project_id__put>`__
130137
:type prediction_preference: dict, optional
131138
:return: updated project
@@ -140,6 +147,8 @@ def update_project(
140147
project_update["app_id"] = app_id
141148
if prediction_preference:
142149
project_update["prediction_preference"] = prediction_preference
150+
if auto_apply_recs is not None:
151+
project_update["auto_apply_recs"] = auto_apply_recs
143152
if prediction_params:
144153
project_update["prediction_params"] = prediction_params
145154

sync/cli/projects.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,19 @@ def get(project: dict):
6262
type=click.Choice(Preference),
6363
default=CONFIG.default_prediction_preference,
6464
)
65+
@click.option(
66+
"--auto-apply-recs",
67+
is_flag=True,
68+
default=False,
69+
help="Automatically apply project recommendations",
70+
)
6571
@click.option(
6672
"-i", "--app-id", help="External identifier often based on the project's target application"
6773
)
6874
def create(
6975
name: str,
7076
product_code: str,
77+
auto_apply_recs: bool,
7178
description: str = None,
7279
job_id: str = None,
7380
location: str = None,
@@ -84,6 +91,7 @@ def create(
8491
job_id=job_id,
8592
cluster_log_url=location,
8693
prediction_preference=preference,
94+
auto_apply_recs=auto_apply_recs,
8795
app_id=app_id,
8896
)
8997
project = response.result
@@ -106,15 +114,24 @@ def create(
106114
type=click.Choice(Preference),
107115
default=CONFIG.default_prediction_preference,
108116
)
117+
@click.option("--auto-apply-recs", type=bool, help="Automatically apply project recommendations")
109118
def update(
110119
project_id: str,
111120
description: str = None,
112121
location: str = None,
113122
app_id: str = None,
114123
preference: Preference = None,
124+
auto_apply_recs: bool = None,
115125
):
116126
"""Update a project"""
117-
response = update_project(project_id, description, location, app_id, preference)
127+
response = update_project(
128+
project_id,
129+
description=description,
130+
s3_url=location,
131+
app_id=app_id,
132+
prediction_preference=preference,
133+
auto_apply_recs=auto_apply_recs,
134+
)
118135
if response.result:
119136
click.echo("Project updated")
120137
else:

0 commit comments

Comments
 (0)