Skip to content

Commit 090b2d1

Browse files
committed
Revert "deploy model in workspace" - Will be released soon.
1 parent 87ee782 commit 090b2d1

File tree

1 file changed

+1
-72
lines changed

1 file changed

+1
-72
lines changed

roboflow/core/workspace.py

Lines changed: 1 addition & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
from __future__ import annotations
2-
31
import concurrent.futures
42
import glob
53
import json
@@ -12,12 +10,11 @@
1210

1311
from roboflow.adapters import rfapi
1412
from roboflow.adapters.rfapi import AnnotationSaveError, ImageUploadError, RoboflowError
15-
from roboflow.config import API_URL, APP_URL, CLIP_FEATURIZE_URL, DEMO_KEYS
13+
from roboflow.config import API_URL, CLIP_FEATURIZE_URL, DEMO_KEYS
1614
from roboflow.core.project import Project
1715
from roboflow.util import folderparser
1816
from roboflow.util.active_learning_utils import check_box_size, clip_encode, count_comparisons
1917
from roboflow.util.image_utils import load_labelmap
20-
from roboflow.util.model_processor import process
2118
from roboflow.util.two_stage_utils import ocr_infer
2219

2320

@@ -569,74 +566,6 @@ def active_learning(
569566
prediction_results if type(raw_data_location) is not np.ndarray else prediction_results[-1]["predictions"]
570567
)
571568

572-
def deploy_model(
573-
self,
574-
model_type: str,
575-
model_path: str,
576-
project_ids: list[str],
577-
model_name: str,
578-
filename: str = "weights/best.pt",
579-
):
580-
"""Uploads provided weights file to Roboflow.
581-
582-
Args:
583-
model_type (str): The type of the model to be deployed.
584-
model_path (str): File path to the model weights to be uploaded.
585-
project_ids (list[str]): List of project IDs to deploy the model to.
586-
filename (str, optional): The name of the weights file. Defaults to "weights/best.pt".
587-
"""
588-
589-
if not project_ids:
590-
raise ValueError("At least one project ID must be provided")
591-
592-
# Validate if provided project URLs belong to user's projects
593-
user_projects = set(project.split("/")[-1] for project in self.projects())
594-
for project_id in project_ids:
595-
if project_id not in user_projects:
596-
raise ValueError(f"Project {project_id} is not accessible in this workspace")
597-
598-
zip_file_name = process(model_type, model_path, filename)
599-
600-
if zip_file_name is None:
601-
raise RuntimeError("Failed to process model")
602-
603-
self._upload_zip(model_type, model_path, project_ids, model_name, zip_file_name)
604-
605-
def _upload_zip(
606-
self,
607-
model_type: str,
608-
model_path: str,
609-
project_ids: list[str],
610-
model_name: str,
611-
model_file_name: str,
612-
):
613-
# This endpoint returns a signed URL to upload the model
614-
res = requests.post(
615-
f"{API_URL}/{self.url}/models/prepareUpload?api_key={self.__api_key}&modelType={model_type}&modelName={model_name}&projectIds={','.join(project_ids)}&nocache=true"
616-
)
617-
try:
618-
res.raise_for_status()
619-
except Exception as e:
620-
print(f"An error occured when getting the model deployment URL: {e}")
621-
return
622-
623-
# Upload the model to the signed URL
624-
res = requests.put(
625-
res.json()["url"],
626-
data=open(os.path.join(model_path, model_file_name), "rb"),
627-
)
628-
try:
629-
res.raise_for_status()
630-
631-
for project_id in project_ids:
632-
print(
633-
f"View the status of your deployment for project {project_id} at:"
634-
f" {APP_URL}/{self.url}/{project_id}/models"
635-
)
636-
637-
except Exception as e:
638-
print(f"An error occured when uploading the model: {e}")
639-
640569
def __str__(self):
641570
projects = self.projects()
642571
json_value = {"name": self.name, "url": self.url, "projects": projects}

0 commit comments

Comments
 (0)