Skip to content

Commit f73f029

Browse files
fix(pre_commit): 🎨 auto format pre-commit hooks
1 parent bbda11a commit f73f029

File tree

2 files changed

+36
-50
lines changed

2 files changed

+36
-50
lines changed

roboflow/core/project.py

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -812,14 +812,9 @@ def image(self, image_id: str) -> Dict:
812812
image_details = data["image"]
813813

814814
return image_details
815-
815+
816816
def create_annotation_job(
817-
self,
818-
name: str,
819-
batch_id: str,
820-
num_images: int,
821-
labeler_email: str,
822-
reviewer_email: str
817+
self, name: str, batch_id: str, num_images: int, labeler_email: str, reviewer_email: str
823818
) -> Dict:
824819
"""
825820
Create a new annotation job in the project.
@@ -850,21 +845,17 @@ def create_annotation_job(
850845
... )
851846
"""
852847
url = f"{API_URL}/{self.__workspace}/{self.__project_name}/jobs?api_key={self.__api_key}"
853-
848+
854849
payload = {
855850
"name": name,
856851
"batch": batch_id,
857852
"num_images": num_images,
858853
"labelerEmail": labeler_email,
859-
"reviewerEmail": reviewer_email
854+
"reviewerEmail": reviewer_email,
860855
}
861-
862-
response = requests.post(
863-
url,
864-
headers={"Content-Type": "application/json"},
865-
json=payload
866-
)
867-
856+
857+
response = requests.post(url, headers={"Content-Type": "application/json"}, json=payload)
858+
868859
if response.status_code != 200:
869860
try:
870861
error_data = response.json()
@@ -873,5 +864,5 @@ def create_annotation_job(
873864
raise RuntimeError(response.text)
874865
except ValueError:
875866
raise RuntimeError(f"Failed to create annotation job: {response.text}")
876-
867+
877868
return response.json()

tests/test_project.py

Lines changed: 28 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -145,14 +145,14 @@ def test_image_invalid_json_response(self):
145145
self.project.image(image_id)
146146

147147
self.assertIn("Expecting value", str(context.exception))
148-
148+
149149
def test_create_annotation_job_success(self):
150150
job_name = "Test Job"
151151
batch_id = "test-batch-123"
152152
num_images = 10
153153
labeler_email = "[email protected]"
154154
reviewer_email = "[email protected]"
155-
155+
156156
expected_response = {
157157
"success": True,
158158
"job": {
@@ -163,68 +163,63 @@ def test_create_annotation_job_success(self):
163163
"labeler": labeler_email,
164164
"reviewer": reviewer_email,
165165
"status": "created",
166-
"created": 1616161616
167-
}
166+
"created": 1616161616,
167+
},
168168
}
169-
169+
170170
expected_url = f"{API_URL}/{WORKSPACE_NAME}/{PROJECT_NAME}/jobs?api_key={ROBOFLOW_API_KEY}"
171-
171+
172172
responses.add(
173173
responses.POST,
174174
expected_url,
175175
json=expected_response,
176176
status=200,
177177
match=[
178-
json_params_matcher({
179-
"name": job_name,
180-
"batch": batch_id,
181-
"num_images": num_images,
182-
"labelerEmail": labeler_email,
183-
"reviewerEmail": reviewer_email
184-
})
185-
]
178+
json_params_matcher(
179+
{
180+
"name": job_name,
181+
"batch": batch_id,
182+
"num_images": num_images,
183+
"labelerEmail": labeler_email,
184+
"reviewerEmail": reviewer_email,
185+
}
186+
)
187+
],
186188
)
187-
189+
188190
result = self.project.create_annotation_job(
189191
name=job_name,
190192
batch_id=batch_id,
191193
num_images=num_images,
192194
labeler_email=labeler_email,
193-
reviewer_email=reviewer_email
195+
reviewer_email=reviewer_email,
194196
)
195-
197+
196198
self.assertEqual(result, expected_response)
197199
self.assertTrue(result["success"])
198200
self.assertEqual(result["job"]["id"], "job-123")
199201
self.assertEqual(result["job"]["name"], job_name)
200-
202+
201203
def test_create_annotation_job_error(self):
202204
job_name = "Test Job"
203205
batch_id = "invalid-batch"
204206
num_images = 10
205207
labeler_email = "[email protected]"
206208
reviewer_email = "[email protected]"
207-
208-
error_response = {
209-
"error": "Batch not found"
210-
}
211-
209+
210+
error_response = {"error": "Batch not found"}
211+
212212
expected_url = f"{API_URL}/{WORKSPACE_NAME}/{PROJECT_NAME}/jobs?api_key={ROBOFLOW_API_KEY}"
213-
214-
responses.add(
215-
responses.POST,
216-
expected_url,
217-
json=error_response,
218-
status=404
219-
)
220-
213+
214+
responses.add(responses.POST, expected_url, json=error_response, status=404)
215+
221216
with self.assertRaises(RuntimeError) as context:
222217
self.project.create_annotation_job(
223218
name=job_name,
224219
batch_id=batch_id,
225220
num_images=num_images,
226221
labeler_email=labeler_email,
227-
reviewer_email=reviewer_email
222+
reviewer_email=reviewer_email,
228223
)
229-
224+
230225
self.assertEqual(str(context.exception), "Batch not found")

0 commit comments

Comments
 (0)