Skip to content
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

feat(robot server): add a POST method on the analyses endpoint #14828

Merged
merged 2 commits into from
Apr 8, 2024

Conversation

sanni-t
Copy link
Member

@sanni-t sanni-t commented Apr 7, 2024

Closes AUTH-255

Overview

Adds a POST method to the existing /protocols/{protocolId}/analyses endpoint in order to post a new analysis for an existing protocol.

This endpoint will take a request body with two optional fields:

  • runTimeParameterValues
  • forceReAnalyze

The new method can affect the analyses in three ways:

  1. When the request is sent with forceReAnalyze=True, the server will unconditionally start a new analysis for the protocol using any RTP data sent along with it. It will return a 201 CREATED status and respond with a list of analysis summaries of all the analyses (ordered oldest first), including the newly started analysis.
  2. When the request is sent without the forceReAnalyze field (or with forceReAnalyze=False), then the server will check the last analysis of the protocol
    • if the RTP values used for it were different from the RTP values sent with the current request, then the server will start a new analysis using the new RTP values. It will return a 201 CREATED status and respond with a list of analysis summaries of all the analyses, including the newly started analysis.
    • if the RTP values used for it were the same as the RTP values sent with the current request, then the server will NOT start a new analysis. It will return a 200 OK status, and simply return the existing list of analysis summaries.

This request requires the last analysis of the protocol to have been completed before handling this request. If the last analysis is pending, it will return a 503 error.

Test Plan

Test out the above three cases and anything else you can think might affect the behavior.
It's pretty well tested in unit & integration tests and it is also the same logic used for handling analyses from POST /protocols, so it is expected to work well when used as tested in integration tests.

Review requests

Usual review for code sanity check.

Risk assessment

Low. New HTTP API not yet used anywhere.

@sanni-t sanni-t requested review from a team as code owners April 7, 2024 06:45
Copy link
Contributor

@SyntaxColoring SyntaxColoring left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code looks great, thanks. 🔬

No notes other than that we'll need to auto-delete old analyses so they don't accumulate indefinitely, which I think you're already aware of.

Comment on lines +580 to +592
"""Start a new analysis for the given existing protocol.

Starts a new analysis for the protocol along with the provided run-time parameter
values (if any), and appends it to the existing analyses.

If the last analysis in the existing analyses used the same RTP values, then a new
analysis is not created.

If `forceAnalyze` is True, this will always start a new analysis.

Returns: List of analysis summaries available for the protocol, ordered as
most recently started analysis last.
"""
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if this is intentional, but FYI, none of this docstring will show up in the HTTP API docs—it gets overridden by the description in the decorator.

default={},
description="Key-value pairs of run-time parameters defined in a protocol.",
)
forceReAnalyze: bool = Field(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI this doesn't quite match the name you have in the method docstring. forceReAnalyze vs. forceAnalyze.

@y3rsh y3rsh merged commit 75acb05 into edge Apr 8, 2024
7 checks passed
@y3rsh y3rsh deleted the AUTH-255-robot-server-create-a-new-analysis-endpoint branch April 8, 2024 22:50
Carlos-fernandez pushed a commit that referenced this pull request May 20, 2024
Closes AUTH-255

# Overview

Adds a POST method to the existing `/protocols/{protocolId}/analyses`
endpoint in order to post a new analysis for an existing protocol.

This endpoint will take a request body with two optional fields:
- `runTimeParameterValues`
- `forceReAnalyze`

The new method can affect the analyses in three ways:
1. When the request is sent with `forceReAnalyze=True`, the server will
unconditionally start a new analysis for the protocol using any RTP data
sent along with it. It will return a 201 CREATED status and respond with
a list of analysis summaries of all the analyses (ordered oldest first),
including the newly started analysis.
2. When the request is sent without the `forceReAnalyze` field (or with
`forceReAnalyze=False`), then the server will check the last analysis of
the protocol
- if the RTP values used for it were **different** from the RTP values
sent with the current request, then the server will start a new analysis
using the new RTP values. It will return a 201 CREATED status and
respond with a list of analysis summaries of all the analyses, including
the newly started analysis.
- if the RTP values used for it were the **same** as the RTP values sent
with the current request, then the server will **NOT** start a new
analysis. It will return a 200 OK status, and simply return the existing
list of analysis summaries.

This request requires the last analysis of the protocol to have been
completed before handling this request. If the last analysis is pending,
it will return a 503 error.

# Test Plan

Test out the above three cases and anything else you can think might
affect the behavior.
It's pretty well tested in unit & integration tests and it is also the
same logic used for handling analyses from `POST /protocols`, so it is
expected to work well when used as tested in integration tests.

# Review requests

Usual review for code sanity check.

# Risk assessment

Low. New HTTP API not yet used anywhere.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants