Skip to content

Commit 5c8e316

Browse files
Update Readme and tests (#40)
* Update Readme to have conda-forge install cmd * updates to batch status tests * Updated readme with more examples
1 parent 9ea606f commit 5c8e316

File tree

2 files changed

+51
-6
lines changed

2 files changed

+51
-6
lines changed

README.rst

Lines changed: 47 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ ____________
2424
.. code-block:: bash
2525
2626
$ pip install --upgrade scaleapi
27+
28+
.. code-block:: bash
29+
30+
$ conda install -c conda-forge scaleapi
2731
2832
Usage
2933
_____
@@ -105,7 +109,31 @@ Task Attributes
105109

106110
The older ``param_dict`` attribute is now replaced with a method ``as_dict()`` to return a task's all attributes as a dictionary (JSON).
107111

108-
First-level attributes of Task are accessible with ``.`` annotation as the following:
112+
.. code-block :: python
113+
114+
task.as_dict()
115+
116+
# {
117+
# 'task_id': '30553edd0b6a93f8f05f0fee',
118+
# 'created_at': '2021-06-17T21:46:36.359Z',
119+
# 'type': 'imageannotation',
120+
# 'status': 'pending',
121+
# ....
122+
# 'params': {
123+
# 'attachment': 'http://i.imgur.com/v4cBreD.jpg',
124+
# 'attachment_type': 'image',
125+
# 'geometries': {
126+
# 'box': {
127+
# 'objects_to_annotate': ['Baby Cow', 'Big Cow'],
128+
# 'min_height': 10,
129+
# 'min_width': 10,
130+
# ...
131+
# },
132+
# 'project': 'My Project',
133+
# ...
134+
# }
135+
136+
First-level attributes of Task are also accessible with ``.`` annotation as the following:
109137

110138
.. code-block :: python
111139
@@ -342,7 +370,6 @@ ________
342370

343371
Files are a way of uploading local files directly to Scale storage or importing files before creating tasks.
344372

345-
The ``file.attachment_url`` can be used in place of attachments in task payload.
346373

347374
Upload Files
348375
^^^^^^^^^^^^^^
@@ -359,6 +386,23 @@ __ https://docs.scale.com/reference#file-upload-1
359386
project_name = "test_project",
360387
)
361388
389+
The ``file.attachment_url`` can be used in place of attachments in task payload.
390+
391+
392+
.. code-block:: python
393+
394+
my_file.as_dict()
395+
396+
# {
397+
# 'attachment_url': 'scaledata://606e2a0a46102303a130949/8ac09a90-c143-4154-9a9b-6c35121396d1f',
398+
# 'created_at': '2021-06-17T21:56:53.825Z',
399+
# 'id': '8ac09d70-ca43-4354-9a4b-6c3591396d1f',
400+
# 'mime_type': 'image/png',
401+
# 'project_names': ['test_project'],
402+
# 'size': 340714,
403+
# 'updated_at': '2021-06-17T21:56:53.825Z'
404+
# }
405+
362406
Import Files
363407
^^^^^^^^^^^^^^
364408

@@ -384,7 +428,7 @@ The attribute can be passed to the task payloads, in the ``attachment`` paramete
384428
...
385429
...
386430
attachment_type = "image",
387-
attachment = my_file.attachment_url,
431+
attachment = my_file.attachment_url, # scaledata://606e2a30949/89a90-c143-4154-9a9b-6c36d1f
388432
...
389433
...
390434
)

tests/test_client.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import pytest
99

1010
import scaleapi
11+
from scaleapi.batches import BatchStatus
1112
from scaleapi.exceptions import (
1213
ScaleDuplicateTask,
1314
ScaleInvalidRequest,
@@ -346,18 +347,18 @@ def test_finalize_batch():
346347
def test_get_batch_status():
347348
batch = create_a_batch()
348349
client.batch_status(batch.name)
349-
assert batch.status == "staging"
350+
assert batch.status == BatchStatus.InProgress.value
350351

351352
batch2 = client.get_batch(batch.name)
352353
batch2.get_status() # Test status update
353-
assert batch2.status == "staging"
354+
assert batch2.status == BatchStatus.InProgress.value
354355

355356

356357
def test_get_batch():
357358
batch = create_a_batch()
358359
batch2 = client.get_batch(batch.name)
359360
assert batch.name == batch2.name
360-
assert batch2.status == "staging"
361+
assert batch2.status == BatchStatus.InProgress.value
361362

362363

363364
def test_batches():

0 commit comments

Comments
 (0)