Skip to content

Commit 5801eb2

Browse files
Batch refactor update (#49)
1 parent 99685d9 commit 5801eb2

34 files changed

+596
-467
lines changed

docs/batch/batch-job-info.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
::: hume._batch.batch_job_info.BatchJobInfo

docs/batch/batch-job-result.md

Lines changed: 0 additions & 1 deletion
This file was deleted.

docs/batch/batch-job-state.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
::: hume._batch.batch_job_state.BatchJobState

docs/index.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,12 @@ job = client.submit_job(urls, [config])
3636
print(job)
3737
print("Running...")
3838

39-
result = job.await_complete()
40-
result.download_predictions("predictions.json")
39+
job.await_complete()
40+
job.download_predictions("predictions.json")
41+
print("Predictions downloaded to predictions.json")
4142

42-
print("Predictions downloaded!")
43+
job.download_artifacts("artifacts.zip")
44+
print("Artifacts downloaded to artifacts.zip")
4345
```
4446

4547
### Rehydrate a batch job from a job ID

examples/batch-facial-action-coding-system/batch-facial-action-coding-system.ipynb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,15 @@
3030
"print(job)\n",
3131
"print(\"Running...\")\n",
3232
"\n",
33-
"result = job.await_complete()\n",
33+
"job.await_complete()\n",
3434
"download_filepath = \"predictions.json\"\n",
35-
"result.download_predictions(download_filepath)\n",
35+
"job.download_predictions(download_filepath)\n",
3636
"\n",
3737
"print(\"Predictions ready!\")\n",
3838
"print()\n",
3939
"\n",
40-
"with open(\"predictions.json\", \"r\") as fp:\n",
41-
" predictions = json.load(fp)\n",
40+
"with open(\"predictions.json\", \"r\") as f:\n",
41+
" predictions = json.load(f)\n",
4242
" for prediction in predictions:\n",
4343
" for file_data in prediction[\"files\"]:\n",
4444
" face_predictions = file_data[\"models\"][\"face\"]\n",

examples/batch-text-entity-recognition/batch-text-entity-recognition.ipynb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,15 @@
3030
"print(job)\n",
3131
"print(\"Running...\")\n",
3232
"\n",
33-
"result = job.await_complete()\n",
33+
"job.await_complete()\n",
3434
"download_filepath = \"predictions.json\"\n",
35-
"result.download_predictions(download_filepath)\n",
35+
"job.download_predictions(download_filepath)\n",
3636
"\n",
3737
"print(\"Predictions ready!\")\n",
3838
"print()\n",
3939
"\n",
40-
"with open(\"predictions.json\", \"r\") as fp:\n",
41-
" predictions = json.load(fp)\n",
40+
"with open(\"predictions.json\", \"r\") as f:\n",
41+
" predictions = json.load(f)\n",
4242
" for prediction in predictions:\n",
4343
" for file_data in prediction[\"files\"]:\n",
4444
" ner_predictions = file_data[\"models\"][\"ner\"]\n",

examples/batch-text-sentiment-analysis/batch-text-sentiment-analysis.ipynb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,15 @@
3030
"print(job)\n",
3131
"print(\"Running...\")\n",
3232
"\n",
33-
"result = job.await_complete()\n",
33+
"job.await_complete()\n",
3434
"download_filepath = \"predictions.json\"\n",
35-
"result.download_predictions(download_filepath)\n",
35+
"job.download_predictions(download_filepath)\n",
3636
"\n",
3737
"print(\"Predictions ready!\")\n",
3838
"print()\n",
3939
"\n",
40-
"with open(\"predictions.json\", \"r\") as fp:\n",
41-
" predictions = json.load(fp)\n",
40+
"with open(\"predictions.json\", \"r\") as f:\n",
41+
" predictions = json.load(f)\n",
4242
" for prediction in predictions:\n",
4343
" for file_data in prediction[\"files\"]:\n",
4444
" language_predictions = file_data[\"models\"][\"language\"]\n",

examples/batch-text-toxicity-detection/batch-text-toxicity-detection.ipynb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,15 @@
3030
"print(job)\n",
3131
"print(\"Running...\")\n",
3232
"\n",
33-
"result = job.await_complete()\n",
33+
"job.await_complete()\n",
3434
"download_filepath = \"predictions.json\"\n",
35-
"result.download_predictions(download_filepath)\n",
35+
"job.download_predictions(download_filepath)\n",
3636
"\n",
3737
"print(\"Predictions ready!\")\n",
3838
"print()\n",
3939
"\n",
40-
"with open(\"predictions.json\", \"r\") as fp:\n",
41-
" predictions = json.load(fp)\n",
40+
"with open(\"predictions.json\", \"r\") as f:\n",
41+
" predictions = json.load(f)\n",
4242
" for prediction in predictions:\n",
4343
" for file_data in prediction[\"files\"]:\n",
4444
" language_predictions = file_data[\"models\"][\"language\"]\n",

examples/batch-voice-expression/batch-voice-expression.ipynb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,14 @@
3232
"print(job)\n",
3333
"print(\"Running...\")\n",
3434
"\n",
35-
"result = job.await_complete()\n",
35+
"job.await_complete()\n",
3636
"download_filepath = \"predictions.json\"\n",
37-
"result.download_predictions(download_filepath)\n",
37+
"job.download_predictions(download_filepath)\n",
3838
"\n",
3939
"print(\"Predictions ready!\")\n",
4040
"\n",
41-
"with open(\"predictions.json\", \"r\") as fp:\n",
42-
" predictions = json.load(fp)\n",
41+
"with open(\"predictions.json\", \"r\") as f:\n",
42+
" predictions = json.load(f)\n",
4343
" for prediction in predictions:\n",
4444
" for file_data in prediction[\"files\"]:\n",
4545
" print()\n",

hume/__init__.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""Module init."""
22
from importlib.metadata import version
33

4-
from hume._batch import BatchJob, BatchJobResult, BatchJobStatus, HumeBatchClient
4+
from hume._batch import BatchJob, BatchJobInfo, BatchJobState, BatchJobStatus, HumeBatchClient, TranscriptionConfig
55
from hume._stream import HumeStreamClient, StreamSocket
66
from hume.error.hume_client_exception import HumeClientException
77

@@ -10,10 +10,12 @@
1010
__all__ = [
1111
"__version__",
1212
"BatchJob",
13-
"BatchJobResult",
13+
"BatchJobInfo",
14+
"BatchJobState",
1415
"BatchJobStatus",
1516
"HumeBatchClient",
1617
"HumeClientException",
1718
"HumeStreamClient",
1819
"StreamSocket",
20+
"TranscriptionConfig",
1921
]

0 commit comments

Comments
 (0)