-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Submit Celery runs based on run_mode instead of API version #956
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Questions & testing:
|
This reverts commit 999a764.
Need to check and raise a validation error if |
…00, incase this somehow happened
rename |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Celery run types are now based on run_mode instead of API version
model.run_mode
field. Instead of based on the API version used (/v1/analyses/{id}/run
vs/v2/analyses/{id}/run
)OASIS_API_VERSION
toOASIS_RUN_MODE
. This select whichrun_mode
workflow a container is running in (2.3.0+
worker images and up)Documentation
Celery Workflows
The OasisPlatform versions
2.3.0
and above now support two types of execution workflow, selected using a newrun_mode
field in an AnalysisModel. (eitherV1
orV2
)Example:
GET /v2/models/1/
Each model must have this field set before an analysis is created, otherwise the server returns a
HTTP 400 - Error: Bad Request
Run Mode V1 - Single server execution
When a model is set to
"run_mode": "V1"
a single task is dispatched (generate_inputs
orgenerate_losses
) to a single worker which then processes that task and returns the result to a WorkerMonitor to store the output and notify the OasisPlatform API server.This is the same workflow used in all OasisPlatform versions starting with
1.x.x
, so if a worker image is versioned from a stable branch starting with1
e.g.1.15.x
1.23.x
1.26.x
1.27.x
1.28.x
Then it can only support the
V1
workflow and the model needs to be set accordinglyRun Mode V2 - Distributed execution
Model is set to
"run_mode": "V2"
use a newer workflow that can horizontally scale to run onn
workers in parallel.Versioned API (v1 / v2)
There are now two API versions for backwards compatibility, which is also labelled
v1
andv2
. The endpoints starting withv1
mirror the API specification from the1.x.x
OasisPlatforms and do not include the newer additions needed for horizontal scaling.v1 endpoints
only supports
"run_mode": "V1"
Validation has been added to ensure the
v1
endpoints are 'locked' to only using models marked as"run_mode": "V1"
.the
/v1/models/
list operation filters out any models marked asV2
.If a model attached to an analysis is switched from
"run_mode": "V1"
to"run_mode": "V2"
then a POSTto either
/v1/analyses/{id}/generate_inputs/
or/v1/analyses/{id}/run/
will returnHTTP 400 - Error: Bad Request
v2 endpoints
supports both
"run_mode": "V1"
and"run_mode": "V2"
. When a request is posted to/v2/analyses/{id}/run/
the API server with check the value stored in the attached modelsrun_mode
field and dispatch the celery task matching that workflow.However, there is an exception which is the endpoint
/v2/analyses/{id}/generate_and_run/
which executes both input generation and losses in a single call. This is only supported in the distributed worked flow so is 'locked' toV2
only.If a request is send to an analysis linked to a model with
"run_mode": "V1"
, then aHTTP 400 - Error: Bad Request
is returned.How a model's
run_mode
is set.1. Directly to model
Both
/v1/models/
and/v2/models/
can update therun_mode
field. Either byPOST
orPATCH
2. auto-registration
If worker containers is set to auto-registration, then the
WorkerMonitor
will know which model queue a container is listening on, so it automaticity setsrun_mode
to match.This works because the
WorkerMonitor-V2
can only receive registration tasks from workers connected to the priority queueCelery-v2
. Since all worker containers running in distributed mode will send its registration task here so we know run_mode should also beV2
The same is true for
WorkerMonitor-V1
andCelery
(the non-priority queue), which is the default in all workers1.x.x
.A worker deployed for a Single server workflow execution send their auto-reg task here instead, so
run_mode
must also beV1
3. URL parameter
run_mode_override
The endpoints that support both
V1
andV2
run_mode's have a url parameterrun_mode_override
to force a value, ignoring field set on an AnalysisModel. This only applies to two endpoints/v2/analyses/{id}/generate_inputs/?run_mode_override={V1|V2}
/v2/analyses/{id}/run/?run_mode_override={V1|V2}
4. posting model_settings
The PR OasisLMF/ODS_Tools#86 expanded model_settings.json to include a new
model_run_mode
key.If this key is included in the settings, then when the data is posted to
/v1/models/{id}/settings/
therun_mode
value is update to match the settings data.Example: