Skip to content

Commit 466c5a5

Browse files
author
Matt Sokoloff
committed
requested changes
1 parent f292247 commit 466c5a5

File tree

2 files changed

+14
-9
lines changed

2 files changed

+14
-9
lines changed

labelbox/schema/project.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ def export_labels(self, timeout_seconds=60):
173173
self.uid)
174174
time.sleep(sleep_time)
175175

176-
def attach_instructions(self, instructions_file: str):
176+
def upsert_instructions(self, instructions_file: str):
177177
"""
178178
* Uploads instructions to the UI. Running more than once will replace the instructions
179179
@@ -189,16 +189,16 @@ def attach_instructions(self, instructions_file: str):
189189

190190
if self.setup_complete is None:
191191
raise ValueError(
192-
"Cannot attach instructions to a project that has not been setup."
192+
"Cannot attach instructions to a project that has not been set up."
193193
)
194194

195195
frontend = self.labeling_frontend()
196196
frontendId = frontend.uid
197197

198198
if frontend.name != "Editor":
199199
logger.warn(
200-
f"This function has only been tested to work with the Editor front end. Found {frontend.name}"
201-
)
200+
f"This function has only been tested to work with the Editor front end. Found %s",
201+
frontend.name)
202202

203203
supported_instruction_formats = (".text", ".txt", ".pdf", ".html")
204204
if not instructions_file.endswith(supported_instruction_formats):

tests/integration/test_project.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import pytest
22
import json
3+
import requests
34

45
from labelbox import Project, LabelingFrontend
56
from labelbox.exceptions import InvalidQueryError
@@ -68,8 +69,11 @@ def test_extend_reservations(project):
6869

6970

7071
def test_attach_instructions(client, project):
71-
with pytest.raises(ValueError):
72-
project.attach_instructions('/tmp/instructions.txt')
72+
with pytest.raises(ValueError) as execinfo:
73+
project.upsert_instructions('/tmp/instructions.txt')
74+
assert str(
75+
execinfo.value
76+
) == "Cannot attach instructions to a project that has not been set up."
7377

7478
editor = list(
7579
client.get_labeling_frontends(
@@ -80,10 +84,11 @@ def test_attach_instructions(client, project):
8084
with open('/tmp/instructions.txt', 'w') as file:
8185
file.write("some instructions...")
8286

83-
project.attach_instructions('/tmp/instructions.txt')
87+
project.upsert_instructions('/tmp/instructions.txt')
8488
assert json.loads(
8589
list(project.labeling_frontend_options())
8690
[-1].customization_options).get('projectInstructions') is not None
8791

88-
with pytest.raises(ValueError):
89-
project.attach_instructions('/tmp/file.invalid_file_extension')
92+
with pytest.raises(ValueError) as execinfo:
93+
project.upsert_instructions('/tmp/file.invalid_file_extension')
94+
assert "instructions_file must end with one of" in str(execinfo.value)

0 commit comments

Comments
 (0)