Skip to content

Commit 3cdfe82

Browse files
committed
Project deployment by name
1 parent ff367a2 commit 3cdfe82

File tree

6 files changed

+21
-10
lines changed

6 files changed

+21
-10
lines changed

examples/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ This code sample shows how to get a deployment from the server.
138138
> geti = Geti(server_config=server_config)
139139
>
140140
> # Create deployment for the project, and prepare it for running inference
141-
> deployment = geti.deploy_project(PROJECT_NAME)
141+
> deployment = geti.deploy_project(project_name=PROJECT_NAME)
142142
>
143143
> # Save deployment on local
144144
> deployment.save(PATH_TO_DEPLOYMENT)

geti_sdk/geti.py

+12-3
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,7 @@ def download_project_data(
371371
# Download deployment
372372
if include_deployment:
373373
logging.info("Creating deployment for project...")
374-
self.deploy_project(project, output_folder=target_folder)
374+
self.deploy_project(project=project, output_folder=target_folder)
375375

376376
logging.info(f"Project '{project.name}' was downloaded successfully.")
377377
return project
@@ -1132,7 +1132,8 @@ def upload_and_predict_video(
11321132

11331133
def deploy_project(
11341134
self,
1135-
project: Project,
1135+
project: Optional[Project] = None,
1136+
project_name: Optional[str] = None,
11361137
output_folder: Optional[Union[str, os.PathLike]] = None,
11371138
models: Optional[Sequence[BaseModel]] = None,
11381139
enable_explainable_ai: bool = False,
@@ -1147,7 +1148,10 @@ def deploy_project(
11471148
for each task in the project. However, it is possible to specify a particular
11481149
model to use, by passing it in the list of `models` as input to this method.
11491150
1150-
:param project: Project object to deploy
1151+
:param project: Project object to deploy. Either `project` or `project_name`
1152+
must be specified.
1153+
:param project_name: Name of the project to deploy. Either `project` or
1154+
`project_name` must be specified.
11511155
:param output_folder: Path to a folder on local disk to which the Deployment
11521156
should be downloaded. If no path is specified, the deployment will not be
11531157
saved.
@@ -1165,6 +1169,11 @@ def deploy_project(
11651169
launch an OVMS container serving the models.
11661170
:return: Deployment for the project
11671171
"""
1172+
if project is None and project_name is None:
1173+
raise ValueError("Either `project` or `project_name` must be specified.")
1174+
if project is None:
1175+
project = self.project_client.get_project_by_name(project_name=project_name)
1176+
11681177
deployment_client = self._deployment_clients.get(project.id, None)
11691178
if deployment_client is None:
11701179
# Create deployment client and add to cache.

notebooks/012_post_inference_hooks.ipynb

+2-2
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@
7070
"metadata": {},
7171
"outputs": [],
7272
"source": [
73-
"deployment = geti.deploy_project(PROJECT_NAME)"
73+
"deployment = geti.deploy_project(project=project)"
7474
]
7575
},
7676
{
@@ -101,8 +101,8 @@
101101
"source": [
102102
"import cv2\n",
103103
"\n",
104-
"from geti_sdk.demos import EXAMPLE_IMAGE_PATH\n",
105104
"from geti_sdk import Visualizer\n",
105+
"from geti_sdk.demos import EXAMPLE_IMAGE_PATH\n",
106106
"\n",
107107
"numpy_image = cv2.imread(EXAMPLE_IMAGE_PATH)\n",
108108
"numpy_rgb = cv2.cvtColor(numpy_image, cv2.COLOR_BGR2RGB)\n",

notebooks/014_asynchronous_inference.ipynb

+3-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,9 @@
7575
"source": [
7676
"DEPLOYMENT_FOLDER = \"deployments\"\n",
7777
"\n",
78-
"deployment = geti.deploy_project(PROJECT_NAME, output_folder=DEPLOYMENT_FOLDER)"
78+
"deployment = geti.deploy_project(\n",
79+
" project_name=PROJECT_NAME, output_folder=DEPLOYMENT_FOLDER\n",
80+
")"
7981
]
8082
},
8183
{

tests/nightly/test_nightly_project.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ def test_deployment(
160160

161161
deployment_folder = os.path.join(fxt_temp_directory, project.name)
162162
deployment = fxt_geti_no_vcr.deploy_project(
163-
project,
163+
project=project,
164164
output_folder=deployment_folder,
165165
enable_explainable_ai=True,
166166
)

tests/pre-merge/integration/test_geti.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -518,7 +518,7 @@ def test_deployment(
518518
for _ in range(n_attempts):
519519
try:
520520
deployment = fxt_geti.deploy_project(
521-
project,
521+
project=project,
522522
output_folder=deployment_folder,
523523
enable_explainable_ai=True,
524524
)
@@ -576,7 +576,7 @@ def test_post_inference_hooks(
576576
project = fxt_project_service.project
577577
deployment_folder = os.path.join(fxt_temp_directory, project.name)
578578

579-
deployment = fxt_geti.deploy_project(project)
579+
deployment = fxt_geti.deploy_project(project=project)
580580
dataset_name = "Test hooks"
581581

582582
# Add a GetiDataCollectionHook

0 commit comments

Comments
 (0)