Skip to content

Commit a74e2f1

Browse files
committed
fix: preserve low-level annotation job adapter
1 parent b1df0df commit a74e2f1

6 files changed

Lines changed: 29 additions & 48 deletions

File tree

roboflow/adapters/rfapi.py

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1056,7 +1056,22 @@ def list_annotation_job_images(api_key, workspace_url, project_url, job_id, *, l
10561056
return _annotation_administration_response(response)
10571057

10581058

1059-
def create_annotation_job(
1059+
def create_annotation_job(api_key, workspace_url, project_url, *, name, batch_id=None, assignees=None):
1060+
"""Create an annotation job with the established low-level adapter contract."""
1061+
payload = {"name": name}
1062+
if batch_id:
1063+
payload["batchId"] = batch_id
1064+
if assignees:
1065+
payload["assignees"] = assignees
1066+
response = requests.post(
1067+
f"{API_URL}/{workspace_url}/{project_url}/jobs",
1068+
params={"api_key": api_key},
1069+
json=payload,
1070+
)
1071+
return _annotation_administration_response(response)
1072+
1073+
1074+
def create_annotation_job_from_batch(
10601075
api_key,
10611076
workspace_url,
10621077
project_url,
@@ -1068,7 +1083,7 @@ def create_annotation_job(
10681083
num_images=None,
10691084
instructions=None,
10701085
):
1071-
"""Create a job through the established jobs endpoint."""
1086+
"""Create a fully assigned job through the established jobs endpoint."""
10721087
payload = {
10731088
"name": name,
10741089
"batch": batch_id,

roboflow/cli/handlers/annotation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ def job_create(
221221
"""Create an annotation job from a batch."""
222222
_simple_command(
223223
ctx_to_args(ctx, project=project),
224-
"create_annotation_job",
224+
"create_annotation_job_from_batch",
225225
batch_id=batch,
226226
labeler_email=labeler,
227227
reviewer_email=reviewer,

roboflow/core/project.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -999,7 +999,7 @@ def create_annotation_job(
999999
if not batch_id or not labeler_email or not reviewer_email:
10001000
raise ValueError("batch_id, labeler_email, and reviewer_email are required")
10011001
try:
1002-
return rfapi.create_annotation_job(
1002+
return rfapi.create_annotation_job_from_batch(
10031003
self.__api_key,
10041004
self.__workspace,
10051005
self.__project_name,

tests/adapters/test_rfapi_phase2.py

Lines changed: 7 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -91,73 +91,39 @@ def test_success(self, mock_post):
9191
from roboflow.adapters.rfapi import create_annotation_job
9292

9393
mock_post.return_value = MagicMock(status_code=201, json=lambda: {"job": {"id": "j2"}})
94-
result = create_annotation_job(
95-
"key",
96-
"ws",
97-
"proj",
98-
name="my-job",
99-
batch_id="b1",
100-
labeler_email="labeler@example.com",
101-
reviewer_email="reviewer@example.com",
102-
)
94+
result = create_annotation_job("key", "ws", "proj", name="my-job", batch_id="b1")
10395
self.assertEqual(result["job"]["id"], "j2")
10496
# Verify URL and payload
10597
call_args = mock_post.call_args
10698
self.assertIn("/ws/proj/jobs", call_args[0][0])
10799
payload = call_args[1]["json"]
108100
self.assertEqual(payload["name"], "my-job")
109-
self.assertEqual(payload["batch"], "b1")
110-
self.assertEqual(payload["labelerEmail"], "labeler@example.com")
111-
self.assertEqual(payload["reviewerEmail"], "reviewer@example.com")
101+
self.assertEqual(payload["batchId"], "b1")
112102

113103
@patch("roboflow.adapters.rfapi.requests.post")
114104
def test_success_200(self, mock_post):
115105
from roboflow.adapters.rfapi import create_annotation_job
116106

117107
mock_post.return_value = MagicMock(status_code=200, json=lambda: {"job": {"id": "j3"}})
118-
result = create_annotation_job(
119-
"key",
120-
"ws",
121-
"proj",
122-
batch_id="b1",
123-
labeler_email="labeler@example.com",
124-
reviewer_email="reviewer@example.com",
125-
)
108+
result = create_annotation_job("key", "ws", "proj", name="my-job")
126109
self.assertEqual(result["job"]["id"], "j3")
127110

128111
@patch("roboflow.adapters.rfapi.requests.post")
129-
def test_with_optional_fields(self, mock_post):
112+
def test_with_assignees(self, mock_post):
130113
from roboflow.adapters.rfapi import create_annotation_job
131114

132115
mock_post.return_value = MagicMock(status_code=201, json=lambda: {"job": {"id": "j4"}})
133-
create_annotation_job(
134-
"key",
135-
"ws",
136-
"proj",
137-
batch_id="b1",
138-
labeler_email="labeler@example.com",
139-
reviewer_email="reviewer@example.com",
140-
num_images=10,
141-
instructions="Use the guide",
142-
)
116+
create_annotation_job("key", "ws", "proj", name="j", assignees=["a@b.com"])
143117
payload = mock_post.call_args[1]["json"]
144-
self.assertEqual(payload["num_images"], 10)
145-
self.assertEqual(payload["instructionText"], "Use the guide")
118+
self.assertEqual(payload["assignees"], ["a@b.com"])
146119

147120
@patch("roboflow.adapters.rfapi.requests.post")
148121
def test_error(self, mock_post):
149122
from roboflow.adapters.rfapi import RoboflowError, create_annotation_job
150123

151124
mock_post.return_value = MagicMock(status_code=400, text="Bad request")
152125
with self.assertRaises(RoboflowError):
153-
create_annotation_job(
154-
"key",
155-
"ws",
156-
"proj",
157-
batch_id="b1",
158-
labeler_email="labeler@example.com",
159-
reviewer_email="reviewer@example.com",
160-
)
126+
create_annotation_job("key", "ws", "proj", name="j")
161127

162128

163129
class TestListFolders(unittest.TestCase):

tests/cli/test_annotation_handler.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ def test_text_output(self, _resolve, mock_api):
187187
class TestJobCreate(unittest.TestCase):
188188
"""annotation job create"""
189189

190-
@patch("roboflow.adapters.rfapi.create_annotation_job")
190+
@patch("roboflow.adapters.rfapi.create_annotation_job_from_batch")
191191
@patch(_RESOLVE, return_value=("key", "ws", "proj"))
192192
def test_text_output(self, _resolve, mock_api):
193193
mock_api.return_value = {"id": "42", "name": "new-job"}
@@ -225,7 +225,7 @@ def test_text_output(self, _resolve, mock_api):
225225
instructions=None,
226226
)
227227

228-
@patch("roboflow.adapters.rfapi.create_annotation_job")
228+
@patch("roboflow.adapters.rfapi.create_annotation_job_from_batch")
229229
@patch(_RESOLVE, return_value=("key", "ws", "proj"))
230230
def test_json_output(self, _resolve, mock_api):
231231
mock_api.return_value = {"id": "42", "name": "new-job"}

tests/test_project_annotation_administration.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ def test_job_wrappers_delegate_to_rfapi(self):
6060
"reviewer_email": "reviewer@example.com",
6161
"instructions": "Guide",
6262
},
63-
"create_annotation_job",
63+
"create_annotation_job_from_batch",
6464
),
6565
(
6666
"create_annotation_job_admin",

0 commit comments

Comments
 (0)