-
Notifications
You must be signed in to change notification settings - Fork 68
PLT-1016 - Add methods for External Workforce management #1630
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
+188
−1
Closed
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
31276e6
PLT-1016 - Add methods for External Workforce management
paulnoirel be9461b
Add support of ExternalWorkforce as an input for remove_External_work…
paulnoirel de71d69
Expose ExternalWorkforce
paulnoirel 57aa877
Merge branch 'develop' into PNO/PLT-1016-Manage-external-workforces
paulnoirel e08cb0b
Fix typo
paulnoirel be3afc3
Update test to obtain an org id
paulnoirel e79319b
Merge branch 'develop' into PNO/PLT-1016-Manage-external-workforces
paulnoirel b0b7f66
Merge branch 'develop' into PNO/PLT-1016-Manage-external-workforces
paulnoirel e060f88
Merge branch 'develop' into PNO/PLT-1016-Manage-external-workforces
paulnoirel 2c13433
Merge branch 'develop' into PNO/PLT-1016-Manage-external-workforces
paulnoirel 9459cfe
Merge branch 'develop' into PNO/PLT-1016-Manage-external-workforces
paulnoirel 049a784
Merge branch 'develop' into PNO/PLT-1016-Manage-external-workforces
paulnoirel 6328ae8
Merge branch 'develop' into PNO/PLT-1016-Manage-external-workforces
paulnoirel 2382f6d
Remove trailing whitespace, change exception, add test comments
paulnoirel eb16761
Merge branch 'develop' into PNO/PLT-1016-Manage-external-workforces
paulnoirel f5f3638
Merge branch 'develop' into PNO/PLT-1016-Manage-external-workforces
paulnoirel File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
ExternalWorkforce | ||
=============================================================================================== | ||
|
||
.. automodule:: labelbox.schema.external_workforce | ||
:members: | ||
:show-inheritance: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
from labelbox.pydantic_compat import BaseModel | ||
|
||
class ExternalWorkforce(BaseModel): | ||
""" | ||
Represents an external workforce used in the Labelbox system. | ||
|
||
Attributes: | ||
id (str): The unique identifier of the external workforce. | ||
name (str): The name of the external workforce. | ||
""" | ||
id: str | ||
name: str |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
libs/labelbox/tests/integration/test_external_workforce.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
from labelbox import Project, ExternalWorkforce | ||
paulnoirel marked this conversation as resolved.
Show resolved
Hide resolved
|
||
import os | ||
import sys | ||
|
||
def _get_workforce_id_for_test() -> str: | ||
# For this test, we need an additional organization id to connect the project to. | ||
# Given that the SDK is tested against multiple versions of Python, and different environments, | ||
# we decided to choose the organization id from | ||
# https://labelbox.atlassian.net/wiki/spaces/PLT/pages/2110816271/How+to+labelbox-python+SDK+CI+Tests | ||
# | ||
# In particular, we have: | ||
# clum46jsb00jp07z338dh1gvb: for Python 3.8 in staging | ||
# cltp16p2v04dr07ywfgqxf23u: for Python 3.12 in staging | ||
# ckcz6bubudyfi0855o1dt1g9s: for Python 3.8 in production | ||
# cltp1fral01dh07009zsng3zs: for Python 3.12 in production | ||
# | ||
# The idea is that when depending on the environment, if the current version of Python is 3.8, | ||
# then we use the organization id for Python 3.12. This way, We always us a different organization id | ||
# from the current one as an external workforce to avoid conflict. | ||
|
||
# Note: A better approach would be to create a new organization dynamically for testing purpose. | ||
# This is not currently possible. | ||
current_version = sys.version_info[:2] | ||
|
||
if os.environ['LABELBOX_TEST_ENVIRON'] == "staging": | ||
paulnoirel marked this conversation as resolved.
Show resolved
Hide resolved
|
||
return "cltp16p2v04dr07ywfgqxf23u" if current_version == (3, 8) else "clum46jsb00jp07z338dh1gvb" | ||
else: | ||
return "cltp1fral01dh07009zsng3zs" if current_version == (3, 8) else "ckcz6bubudyfi0855o1dt1g9s" | ||
|
||
|
||
def test_add_external_workforce(project: Project): | ||
workforce_id = _get_workforce_id_for_test() | ||
|
||
external_workforces = project.add_external_workforce(workforce_id) | ||
assert len(external_workforces) == 1 | ||
assert isinstance(external_workforces[0], ExternalWorkforce) | ||
|
||
|
||
def test_get_external_workforces(project: Project): | ||
workforce_id = _get_workforce_id_for_test() | ||
|
||
external_workforces = project.add_external_workforce(workforce_id) | ||
|
||
external_workforces = project.get_external_workforces() | ||
assert len(external_workforces) == 1 | ||
assert isinstance(external_workforces[0], ExternalWorkforce) | ||
|
||
|
||
def test_remove_external_workforce(project: Project): | ||
workforce_id = _get_workforce_id_for_test() | ||
external_workforces = project.add_external_workforce(workforce_id) | ||
|
||
external_workforces = project.remove_external_workforce(workforce_id) | ||
assert len(external_workforces) == 0 | ||
|
||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.