Skip to content

Commit 384e5a1

Browse files
authored
MRG: Merge pull request #608 from octue/support-automatic-question-retrying
Add ability to automatically retry failed multiple questions
2 parents c481d28 + 5632abf commit 384e5a1

File tree

15 files changed

+668
-346
lines changed

15 files changed

+668
-346
lines changed

.github/workflows/python-ci.yml

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -81,11 +81,15 @@ jobs:
8181
- name: Checkout Repository
8282
uses: actions/checkout@v3
8383

84+
- name: Install Poetry
85+
uses: snok/[email protected]
86+
87+
- name: Build a binary wheel and a source tarball
88+
run: poetry build
89+
8490
- name: Test package is publishable with PyPI test server
85-
uses: JRubics/poetry-[email protected]
91+
uses: pypa/gh-action-pypi-publish@v1.8.10
8692
with:
87-
python_version: "3.9"
88-
pypi_token: ${{ secrets.TEST_PYPI_TOKEN }}
89-
repository_name: "testpypi"
90-
repository_url: "https://test.pypi.org/legacy/"
91-
ignore_dev_requirements: "yes"
93+
repository-url: https://test.pypi.org/legacy/
94+
skip-existing: true
95+
verbose: true

.github/workflows/release.yml

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -83,18 +83,24 @@ jobs:
8383
prerelease: false
8484

8585
publish:
86-
runs-on: ubuntu-latest
8786
needs: release
87+
runs-on: ubuntu-latest
88+
permissions:
89+
id-token: write
90+
contents: read
91+
8892
steps:
8993
- name: Checkout Repository
9094
uses: actions/checkout@v3
9195

92-
- name: Build and publish latest package to PyPI
93-
uses: JRubics/[email protected]
94-
with:
95-
python_version: "3.9"
96-
pypi_token: ${{ secrets.PYPI_TOKEN }}
97-
ignore_dev_requirements: "yes"
96+
- name: Install Poetry
97+
uses: snok/[email protected]
98+
99+
- name: Build a binary wheel and a source tarball
100+
run: poetry build
101+
102+
- name: Publish package distributions to PyPI
103+
uses: pypa/[email protected]
98104

99105
docker:
100106
runs-on: ubuntu-latest

docs/source/asking_questions.rst

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,7 @@ sent back to the parent. If you're not sure how long a particular analysis might
6464
Asking multiple questions in parallel
6565
=====================================
6666
You can also ask multiple questions to a service in parallel. By default, if any of the questions fail, an error is
67-
raised and no answers are returned. If ``raise_errors=False`` is provided, answers are returned for all successful
68-
questions while errors are returned unraised for unsuccessful ones.
67+
raised and no answers are returned.
6968

7069
.. code-block:: python
7170
@@ -80,7 +79,16 @@ questions while errors are returned unraised for unsuccessful ones.
8079
{"output_values": {"different": "result"}, "output_manifest": None},
8180
]
8281
83-
This method uses threads, allowing all the questions to be asked at once instead of one after another.
82+
This method uses multithreading, allowing all the questions to be asked at once instead of one after another.
83+
84+
Options:
85+
86+
- If ``raise_errors=False`` is provided, answers are returned for all successful questions while unraised errors are
87+
returned for unsuccessful ones
88+
- If ``raise_errors=False`` is provided with ``max_retries > 0``, failed questions are retried up to this number of
89+
times
90+
- If ``raise_errors=False`` is provided with ``max_retries > 0`` and ``prevent_retries_when`` is set to a list of
91+
exception types, failed questions are retried except for those whose exception types are in the list
8492

8593

8694
Asking a question within a service

docs/source/inter_service_compatibility.rst

Lines changed: 169 additions & 167 deletions
Large diffs are not rendered by default.
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
FROM windpioneers/gdal-python:little-gecko-gdal-2.4.1-python-3.11-slim
2+
3+
# Ensure print statements and log messages appear promptly in Cloud Logging.
4+
ENV PYTHONUNBUFFERED True
5+
6+
ENV PROJECT_ROOT=/workspace
7+
WORKDIR $PROJECT_ROOT
8+
9+
RUN apt-get update -y && apt-get install -y --fix-missing build-essential && rm -rf /var/lib/apt/lists/*
10+
11+
# Install poetry.
12+
ENV POETRY_HOME=/root/.poetry
13+
ENV PATH "$POETRY_HOME/bin:$PATH"
14+
RUN curl -sSL https://install.python-poetry.org | python3 - && poetry config virtualenvs.create false;
15+
16+
# Copy in the dependencies file(s) for caching. One or more of `requirements.txt`, `setup.py`, and `pyproject.toml and
17+
# `poetry.lock` must be present.
18+
COPY pyproject.tom[l] poetry.loc[k] setup.p[y] requirements.tx[t] ./
19+
20+
# If `pyproject.toml` is present, install the dependencies only to utilise layer caching for quick rebuilds.
21+
RUN if [ -f "pyproject.toml" ]; then poetry install \
22+
--no-ansi \
23+
--no-interaction \
24+
--no-cache \
25+
--no-root \
26+
--only main; \
27+
fi
28+
29+
# Copy local code to the application root directory.
30+
COPY . .
31+
32+
# Install local packages if using poetry. Otherwise, install everything if using `setup.py` or `requirements.txt`.
33+
RUN if [ -f "pyproject.toml" ]; then poetry install --only main; \
34+
elif [ -f "setup.py" ]; then pip install --upgrade pip && pip install -e .; \
35+
elif [ -f "requirements.txt" ]; then pip install --upgrade pip && pip install -r requirements.txt; fi
36+
37+
EXPOSE $PORT
38+
39+
ENV USE_OCTUE_LOG_HANDLER=1
40+
ENV COMPUTE_PROVIDER=GOOGLE_CLOUD_RUN
41+
42+
ARG GUNICORN_WORKERS=1
43+
ENV GUNICORN_WORKERS=$GUNICORN_WORKERS
44+
45+
ARG GUNICORN_THREADS=8
46+
ENV GUNICORN_THREADS=$GUNICORN_THREADS
47+
48+
# Timeout is set to 0 to disable the timeouts of the workers to allow Cloud Run to handle instance scaling.
49+
CMD exec gunicorn --bind :$PORT --workers $GUNICORN_WORKERS --threads $GUNICORN_THREADS --timeout 0 octue.cloud.deployment.google.cloud_run.flask_app:app

octue/metadata/recorded_questions.jsonl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,3 +80,4 @@
8080
{"parent_sdk_version": "0.49.0", "question": {"data": "{\"input_values\": {\"height\": 4, \"width\": 72}, \"input_manifest\": {\"id\": \"34216d6d-e32e-4c40-8b05-ee9bd71966c9\", \"name\": null, \"datasets\": {\"my_dataset\": \"/var/folders/sk/hf5fbp616c77tsys9lz55qn40000gp/T/tmppi1e5t2n\"}}, \"children\": null, \"message_number\": 0}", "attributes": {"question_uuid": "3b1224da-8e7f-4b1b-8ef3-c5cf1a5e698c", "forward_logs": "1", "allow_save_diagnostics_data_on_crash": "1", "octue_sdk_version": "0.49.0"}}}
8181
{"parent_sdk_version": "0.49.1", "question": {"data": "{\"input_values\": {\"height\": 4, \"width\": 72}, \"input_manifest\": {\"id\": \"34216d6d-e32e-4c40-8b05-ee9bd71966c9\", \"name\": null, \"datasets\": {\"my_dataset\": \"/var/folders/sk/hf5fbp616c77tsys9lz55qn40000gp/T/tmppi1e5t2n\"}}, \"children\": null, \"message_number\": 0}", "attributes": {"question_uuid": "3b1224da-8e7f-4b1b-8ef3-c5cf1a5e698c", "forward_logs": "1", "allow_save_diagnostics_data_on_crash": "1", "octue_sdk_version": "0.49.1"}}}
8282
{"parent_sdk_version": "0.49.2", "question": {"data": "{\"input_values\": {\"height\": 4, \"width\": 72}, \"input_manifest\": {\"id\": \"bdadcd12-a51b-4571-9db3-9d240bd15faa\", \"name\": null, \"datasets\": {\"my_dataset\": \"/var/folders/sk/hf5fbp616c77tsys9lz55qn40000gp/T/tmpw3232ii0\"}}, \"children\": null, \"message_number\": 0}", "attributes": {"question_uuid": "0b57da2c-38e2-4f8b-9368-fe35125da8fb", "forward_logs": "1", "allow_save_diagnostics_data_on_crash": "1", "octue_sdk_version": "0.49.2"}}}
83+
{"parent_sdk_version": "0.50.0", "question": {"data": "{\"input_values\": {\"height\": 4, \"width\": 72}, \"input_manifest\": {\"id\": \"2d618d16-2a2b-437b-8db7-d5139e1645f2\", \"name\": null, \"datasets\": {\"my_dataset\": \"/var/folders/sk/hf5fbp616c77tsys9lz55qn40000gp/T/tmpr7jpj4sp\"}}, \"children\": null, \"message_number\": 0}", "attributes": {"question_uuid": "7bc572dc-ab8b-4aed-a132-b0b509caceb3", "forward_logs": "1", "allow_save_diagnostics_data_on_crash": "1", "octue_sdk_version": "0.50.0"}}}

0 commit comments

Comments
 (0)