Skip to content

Commit a77cbf7

Browse files
authored
[PROD-1104] Use project name instead of app_id (#30)
1 parent f20359c commit a77cbf7

File tree

5 files changed

+35
-23
lines changed

5 files changed

+35
-23
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.0.15"
2+
__version__ = "0.1.0"
33

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

sync/api/projects.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,35 +38,43 @@ def get_prediction(project_id: str, preference: Preference = None) -> Response[d
3838

3939

4040
def create_project(
41-
app_id: str,
41+
name: str,
4242
description: str = None,
43+
job_id: str = None,
4344
s3_url: str = None,
4445
prediction_preference: Preference = Preference.ECONOMY,
4546
prediction_params: dict = None,
47+
app_id: str = None,
4648
) -> Response[dict]:
4749
"""Creates a Sync project for tracking and optimizing Apache Spark applications
4850
49-
:param app_id: Apache Spark application name
50-
:type app_id: str
51+
:param name: Project name
52+
:type name: str
5153
:param description: application description, defaults to None
5254
:type description: str, optional
55+
:param job_id: Databricks job ID, defaults to None
56+
:type job_id: str, optional
5357
:param s3_url: S3 URL under which to store project configurations and logs, defaults to None
5458
:type s3_url: str, optional
5559
:param prediction_preference: preferred prediction solution, defaults to `Preference.ECONOMY`
5660
:type prediction_preference: Preference, optional
5761
: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
58-
:type prediction_preference: dict, optional
62+
:type prediction_params: dict, optional
63+
:param app_id: Apache Spark application identifier, defaults to None
64+
:type app_id: str, optional
5965
:return: the newly created project
6066
:rtype: Response[dict]
6167
"""
6268
return Response(
6369
**get_default_client().create_project(
6470
{
65-
"app_id": app_id,
71+
"name": name,
6672
"description": description,
73+
"job_id": job_id,
6774
"s3_url": s3_url,
6875
"prediction_preference": prediction_preference,
6976
"prediction_params": prediction_params,
77+
"app_id": app_id,
7078
}
7179
)
7280
)

sync/cli/projects.py

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def list():
2626
response = get_projects()
2727
projects = response.result
2828
if projects:
29-
click.echo_via_pager(f"{p['updated_at']} {p['id']}: {p['app_id']}\n" for p in projects)
29+
click.echo_via_pager(f"{p['updated_at']} {p['id']}: {p['name']}\n" for p in projects)
3030
else:
3131
click.echo(str(response.error), err=True)
3232

@@ -51,22 +51,38 @@ def get(project: dict):
5151

5252

5353
@projects.command
54-
@click.argument("app-id")
54+
@click.argument("name")
5555
@click.option("-d", "--description")
56+
@click.option("-j", "--job-id", help="Databricks job ID")
5657
@click.option("-l", "--location", help="S3 URL under which to store event logs and configuration")
5758
@click.option(
5859
"-p",
5960
"--preference",
6061
type=click.Choice(Preference),
6162
default=CONFIG.default_prediction_preference,
6263
)
64+
@click.option(
65+
"-i", "--app-id", help="External identifier often based on the project's target application"
66+
)
6367
def create(
64-
app_id: str, description: str = None, location: str = None, preference: Preference = None
68+
name: str,
69+
description: str = None,
70+
job_id: str = None,
71+
location: str = None,
72+
preference: Preference = None,
73+
app_id: str = None,
6574
):
6675
"""Create a project
6776
6877
APP_ID is a name that uniquely identifies an application"""
69-
response = create_project(app_id, description, location, preference)
78+
response = create_project(
79+
name,
80+
description=description,
81+
job_id=job_id,
82+
s3_url=location,
83+
prediction_preference=preference,
84+
app_id=app_id,
85+
)
7086
project = response.result
7187
if project:
7288
click.echo(f"Project ID: {project['id']}")

sync/models.py

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88
from pydantic import BaseModel, Field, root_validator, validator
99
from pydantic.generics import GenericModel
10-
from pydantic.types import UUID4
1110

1211

1312
class Preference(str, Enum):
@@ -21,17 +20,6 @@ class Platform(str, Enum):
2120
AWS_DATABRICKS = "aws-databricks"
2221

2322

24-
class Project(BaseModel):
25-
id: UUID4 = Field(..., description="project UUID")
26-
app_id: str = Field(
27-
...,
28-
description="a string that uniquely identifies an application to the owner of that application",
29-
)
30-
description: Union[str, None] = Field(description="Additional information on the app, or project")
31-
s3_url: Union[str, None] = Field(description="location of data from runs of the application")
32-
prediction_preference: Union[Preference, None] = Field(description="preferred prediction to apply")
33-
34-
3523
class Error(BaseModel):
3624
code: str
3725
message: str

tests/test_awsemr.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ def test_get_project_report(get_project, get_cluster_report):
111111
"created_at": "2023-01-20T00:38:10Z",
112112
"updated_at": "2023-03-10T17:18:50Z",
113113
"id": "4f5fe783-df74-4d64-adad-a635d6319579",
114-
"app_id": "Data Insights",
114+
"name": "Data Insights",
115115
"description": "My first project",
116116
"s3_url": "s3://megacorp-bucket/projects/emr",
117117
"prediction_preference": "balanced",

0 commit comments

Comments
 (0)