Skip to content

Commit 012ebfb

Browse files
authored
Merge pull request #519 from Labelbox/develop
3.17.2
2 parents f15b28c + 92efffd commit 012ebfb

File tree

3 files changed

+25
-32
lines changed

3 files changed

+25
-32
lines changed

CHANGELOG.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
# Changelog
22

3-
# Version 3.17.1 (2022-03-24)
3+
# Version 3.17.2 (2022-03-28)
4+
## Fix
5+
* Project.upsert_instructions now works properly for new projects.
6+
7+
# Version 3.17.1 (2022-03-25)
48
## Updated
59
* Remove unused rasterio dependency
610

labelbox/schema/project.py

Lines changed: 17 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,6 @@ def upsert_instructions(self, instructions_file: str) -> None:
415415
)
416416

417417
frontend = self.labeling_frontend()
418-
frontendId = frontend.uid
419418

420419
if frontend.name != "Editor":
421420
logger.warning(
@@ -428,35 +427,25 @@ def upsert_instructions(self, instructions_file: str) -> None:
428427
f"instructions_file must be a pdf or html file. Found {instructions_file}"
429428
)
430429

431-
lfo = list(self.labeling_frontend_options())[-1]
432430
instructions_url = self.client.upload_file(instructions_file)
433-
customization_options = self.ontology().normalized
434-
customization_options['projectInstructions'] = instructions_url
435-
option_id = lfo.uid
436-
437-
self.client.execute(
438-
"""mutation UpdateFrontendWithExistingOptionsPyApi (
439-
$frontendId: ID!,
440-
$optionsId: ID!,
441-
$name: String!,
442-
$description: String!,
443-
$customizationOptions: String!
431+
432+
query_str = """mutation setprojectinsructionsPyApi($projectId: ID!, $instructions_url: String!) {
433+
setProjectInstructions(
434+
where: {id: $projectId},
435+
data: {instructionsUrl: $instructions_url}
444436
) {
445-
updateLabelingFrontend(
446-
where: {id: $frontendId},
447-
data: {name: $name, description: $description}
448-
) {id}
449-
updateLabelingFrontendOptions(
450-
where: {id: $optionsId},
451-
data: {customizationOptions: $customizationOptions}
452-
) {id}
453-
}""", {
454-
"frontendId": frontendId,
455-
"optionsId": option_id,
456-
"name": frontend.name,
457-
"description": "Video, image, and text annotation",
458-
"customizationOptions": json.dumps(customization_options)
459-
})
437+
id
438+
ontology {
439+
id
440+
options
441+
}
442+
}
443+
}"""
444+
445+
self.client.execute(query_str, {
446+
'projectId': self.uid,
447+
'instructions_url': instructions_url
448+
})
460449

461450
def labeler_performance(self) -> PaginatedCollection:
462451
""" Returns the labeler performances for this Project.

tests/integration/test_project.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import json
2+
import time
23

34
import pytest
45
import requests
@@ -137,9 +138,8 @@ def test_attach_instructions(client, project):
137138
project.setup(editor, empty_ontology)
138139

139140
project.upsert_instructions('tests/integration/media/sample_pdf.pdf')
140-
assert json.loads(
141-
list(project.labeling_frontend_options())
142-
[-1].customization_options).get('projectInstructions') is not None
141+
time.sleep(3)
142+
assert project.ontology().normalized['projectInstructions'] is not None
143143

144144
with pytest.raises(ValueError) as exc_info:
145145
project.upsert_instructions('/tmp/file.invalid_file_extension')

0 commit comments

Comments
 (0)