Skip to content

Commit 65f4dfe

Browse files
authored
Merge pull request #668 from Labelbox/develop
3.25.3
2 parents ffd58b6 + 5b4b4bf commit 65f4dfe

File tree

13 files changed

+456
-173
lines changed

13 files changed

+456
-173
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
# Changelog
2+
# Version 3.25.3 (2022-08-10)
3+
## Fixed
4+
* Label export will continue polling if the downloadUrl is None
25

36
# Version 3.25.2 (2022-07-26)
47
## Updated
@@ -651,3 +654,7 @@ a `Label`. Default value is 0.0.
651654

652655
## Version 2.2 (2019-10-18)
653656
Changelog not maintained before version 2.2.
657+
658+
### Changed
659+
* `Model.create_model_run()`
660+
* Add training metadata config as a model run creation param

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ The Labelbox Python API offers a simple, user-friendly way to interact with the
2020

2121
- Use Python 3.7, 3.8 or 3.9
2222
- [Create an account](http://app.labelbox.com/)
23-
- [Generate an API key](https://labelbox.com/docs/api/getting-started#create_api_key)
23+
- [Generate an API key](https://docs.labelbox.com/docs/create-an-api-key)
2424

2525
## Installation
2626

@@ -59,9 +59,9 @@ pip install labelbox[data]
5959

6060
## Documentation
6161

62-
- [Visit our docs](https://labelbox.com/docs/python-api) to learn how the SDK works
62+
- [Visit our docs](https://docs.labelbox.com/reference) to learn how the SDK works
6363
- Checkout our [notebook examples](examples/) to follow along with interactive tutorials
64-
- view our [API reference](https://labelbox.com/docs/python-api/api-reference).
64+
- view our [API reference](https://labelbox-python.readthedocs.io/en/latest/index.html).
6565

6666
## Authentication
6767

examples/annotation_import/image.ipynb

Lines changed: 409 additions & 155 deletions
Large diffs are not rendered by default.

examples/model_diagnostics/model_diagnostics_guide.ipynb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,8 @@
350350
"source": [
351351
"lb_model = client.create_model(name=f\"{project.name}-model\",\n",
352352
" ontology_id=project.ontology().uid)\n",
353-
"lb_model_run = lb_model.create_model_run(\"0.0.0\")\n",
353+
"lb_model_run_hyperparameters = {\"batch_size\": 1000}\n",
354+
"lb_model_run = lb_model.create_model_run(\"0.0.0\", lb_model_run_hyperparameters)\n",
354355
"lb_model_run.upsert_labels([label.uid for label in labels])"
355356
]
356357
},

labelbox/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name = "labelbox"
2-
__version__ = "3.25.2"
2+
__version__ = "3.25.3"
33

44
from labelbox.client import Client
55
from labelbox.schema.project import Project

labelbox/schema/model.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,23 +18,26 @@ class Model(DbObject):
1818
name = Field.String("name")
1919
model_runs = Relationship.ToMany("ModelRun", False)
2020

21-
def create_model_run(self, name) -> "ModelRun":
21+
def create_model_run(self, name, config=None) -> "ModelRun":
2222
""" Creates a model run belonging to this model.
2323
2424
Args:
2525
name (string): The name for the model run.
26+
config (json): Model run's training metadata config
2627
Returns:
2728
ModelRun, the created model run.
2829
"""
2930
name_param = "name"
31+
config_param = "config"
3032
model_id_param = "modelId"
3133
ModelRun = Entity.ModelRun
32-
query_str = """mutation CreateModelRunPyApi($%s: String!, $%s: ID!) {
33-
createModelRun(data: {name: $%s, modelId: $%s}) {%s}}""" % (
34-
name_param, model_id_param, name_param, model_id_param,
35-
query.results_query_part(ModelRun))
34+
query_str = """mutation CreateModelRunPyApi($%s: String!, $%s: Json, $%s: ID!) {
35+
createModelRun(data: {name: $%s, trainingMetadata: $%s, modelId: $%s}) {%s}}""" % (
36+
name_param, config_param, model_id_param, name_param, config_param,
37+
model_id_param, query.results_query_part(ModelRun))
3638
res = self.client.execute(query_str, {
3739
name_param: name,
40+
config_param: config,
3841
model_id_param: self.uid
3942
})
4043
return ModelRun(self.client, res["createModelRun"])

labelbox/schema/model_run.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ class ModelRun(DbObject):
3232
created_at = Field.DateTime("created_at")
3333
created_by_id = Field.String("created_by_id", "createdBy")
3434
model_id = Field.String("model_id")
35+
training_metadata = Field.Json("training_metadata")
3536

3637
class Status(Enum):
3738
EXPORTING_DATA = "EXPORTING_DATA"

labelbox/schema/project.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ def _validate_datetime(string_date: str) -> bool:
333333
while True:
334334
res = self.client.execute(query_str, {id_param: self.uid})
335335
res = res["exportLabels"]
336-
if not res["shouldPoll"]:
336+
if not res["shouldPoll"] and res["downloadUrl"] is not None:
337337
url = res['downloadUrl']
338338
if not download:
339339
return url

pytest.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
[pytest]
2-
addopts = -s -vv -x --reruns 5 --reruns-delay 10
2+
addopts = -s -vv -x --reruns 5 --reruns-delay 10 --durations=100
33
markers =
44
slow: marks tests as slow (deselect with '-m "not slow"')

tests/integration/annotation_import/test_model_run.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,11 @@ def test_model_run(client, configured_project_with_label, rand_gen):
1414
model = client.create_model(data["name"], data["ontology_id"])
1515

1616
name = rand_gen(str)
17-
model_run = model.create_model_run(name)
17+
config = {"batch_size": 100, "reruns": None}
18+
model_run = model.create_model_run(name, config)
1819
assert model_run.name == name
20+
assert model_run.training_metadata["batchSize"] == config["batch_size"]
21+
assert model_run.training_metadata["reruns"] == config["reruns"]
1922
assert model_run.model_id == model.uid
2023
assert model_run.created_by_id == client.get_user().uid
2124

@@ -32,6 +35,12 @@ def test_model_run(client, configured_project_with_label, rand_gen):
3235
assert fetch_model_run == model_run
3336

3437

38+
def test_model_run_no_config(rand_gen, model):
39+
name = rand_gen(str)
40+
model_run = model.create_model_run(name)
41+
assert model_run.name == name
42+
43+
3544
def test_model_run_delete(client, model_run):
3645
models_before = list(client.get_models())
3746
model_before = models_before[0]

0 commit comments

Comments
 (0)