Skip to content

Commit

Permalink
Merge pull request #257 from Labelbox/develop
Browse files Browse the repository at this point in the history
3.1.0
  • Loading branch information
msokoloff1 authored Aug 19, 2021
2 parents 6f1f0c2 + ebc9bf5 commit 685b23e
Show file tree
Hide file tree
Showing 16 changed files with 431 additions and 903 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# Changelog

# Version 3.1.0 (2021-08-18)
## Added
* Support for new HTML attachment type
* Delete Bulk Import Requests with `BulkImportRequest.delete()`

## Misc
* Updated MEAPredictionImport class to use latest grapqhql endpoints


# Version 3.0.1 (2021-08-12)
## Fix
* Issue with inferring text type from export
Expand Down
7 changes: 7 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@
build:
docker build -t local/labelbox-python:test .


test-local: build
docker run -it -v ${PWD}:/usr/src -w /usr/src \
-e LABELBOX_TEST_ENVIRON="local" \
-e LABELBOX_TEST_API_KEY_LOCAL=${LABELBOX_TEST_API_KEY_LOCAL} \
local/labelbox-python:test pytest $(PATH_TO_TEST) -svvx

test-staging: build
docker run -it -v ${PWD}:/usr/src -w /usr/src \
-e LABELBOX_TEST_ENVIRON="staging" \
Expand Down
44 changes: 34 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,14 @@ If the installation completes with a warning re: pip not being in your path, you
export PATH=/Users/<your-macOS-username>/Library/Python/3.8/bin:$PATH
```

Install using Python's Pip manager.
Install SDK locally, using Python's Pip manager
```
pip install labelbox
pip3 install -e .
```

Install dependencies
```
pip3 install -r requirements.txt
```
To install dependencies required for data processing modules use:
```
Expand All @@ -55,29 +60,48 @@ pip install labelbox[data]
Labelbox uses API keys to validate requests. You can create and manage API keys on [Labelbox](https://app.labelbox.com/account/api-keys). Pass your API key as an environment variable. Then, import and initialize the API Client.

```
user@machine:~$ export LABELBOX_API_KEY="<your api key here>"
user@machine:~$ export LABELBOX_API_KEY="<your local api key here>"
user@machine:~$ python3
from labelbox import Client
client = Client()
```
* Update api_key and endpoint if not using the production cloud deployment
```
# On prem
client = Client( endpoint = "<local deployment>")
# Local
client = Client(api_key=os.environ['LABELBOX_TEST_API_KEY_LOCAL'], endpoint="http://localhost:8080/graphql")
# Staging
client = Client(api_key=os.environ['LABELBOX_TEST_API_KEY_LOCAL'], endpoint="https://staging-api.labelbox.com/graphql")
```

## Contribution
Please consult `CONTRIB.md`

## Testing
1. Update the `Makefile` with your `staging` or `prod` API key. Ensure that docker has been installed on your system. Make sure the key is not from a free tier account.
2. To test on `staging`:
1. Update the `Makefile` with your `local`, `staging`, `prod` API key. Ensure that docker has been installed on your system. Make sure the key is not from a free tier account.
2. To test on `local`:
```
user@machine:~$ export LABELBOX_TEST_API_KEY_LOCAL="<your local api key here>"
make test-local # with an optional flag: PATH_TO_TEST=tests/integration/...etc LABELBOX_TEST_API_KEY_LOCAL=specify_here_or_export_me
```

3. To test on `staging`:
```
make test-staging
user@machine:~$ export LABELBOX_TEST_API_KEY_STAGING="<your staging api key here>"
make test-staging # with an optional flag: PATH_TO_TEST=tests/integration/...etc LABELBOX_TEST_API_KEY_STAGING=specify_here_or_export_me
```

3. To test on `prod`:
4. To test on `prod`:
```
make test-prod
user@machine:~$ export LABELBOX_TEST_API_KEY_PROD="<your prod api key here>"
make test-prod # with an optional flag: PATH_TO_TEST=tests/integration/...etc LABELBOX_TEST_API_KEY_PROD=specify_here_or_export_me
```

4. If you make any changes and need to rebuild the image used for testing, force a rebuild with the `-B` flag
5. If you make any changes and need to rebuild the image used for testing, force a rebuild with the `-B` flag
```
make -B {build|test-staging|test_prod}
make -B {build|test-staging|test-prod}
```
18 changes: 13 additions & 5 deletions examples/model_assisted_labeling/ner_mal.ipynb

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion labelbox/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name = "labelbox"
__version__ = "3.0.1"
__version__ = "3.1.0"

from labelbox.schema.project import Project
from labelbox.client import Client
Expand Down
5 changes: 4 additions & 1 deletion labelbox/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,9 @@ def check_errors(keywords, *path):
return error
return None

def get_error_status_code(error):
return error["extensions"]["exception"]["status"]

if check_errors(["AUTHENTICATION_ERROR"], "extensions",
"code") is not None:
raise labelbox.exceptions.AuthenticationError("Invalid API key")
Expand Down Expand Up @@ -242,7 +245,7 @@ def check_errors(keywords, *path):
if internal_server_error is not None:
message = internal_server_error.get("message")

if message.startswith(("Syntax Error", "Invite(s) cannot be sent")):
if get_error_status_code(internal_server_error) == 400:
raise labelbox.exceptions.InvalidQueryError(message)
else:
raise labelbox.exceptions.InternalServerError(message)
Expand Down
Loading

0 comments on commit 685b23e

Please sign in to comment.