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): show run time parameters in pending analysis #15229

Merged
merged 9 commits into from
Jun 10, 2024

Conversation

sanni-t
Copy link
Member

@sanni-t sanni-t commented May 20, 2024

Closes AUTH-282

Overview

Follow-up to #15217

This PR changes a pending analysis' AnalysisSummary to include the run time parameters (with overrides).
In order to do this, we will now be parsing the RTPs before analysis response is created. This is a very quick process and shouldn't cause any perceptible delays in the response of neither POST /protocols nor POST /runs/.../analyses endpoints, as long as recommended python protocol guidelines are followed.

Test Plan

  • Upload a protocol with run time parameters, verify that the response contains run time parameter definitions along with the values specified in the request
  • Send a POST request on /protocols/{protocolId}/analyses endpoint with different RTP values, or by specifying the forceReanalysis flag, and verify that the newly pending analysis also contains (updated) RTPs
  • Verify that pending summaries in GET endpoints also contain RTPs
  • Verify that summaries of completed analyses don't expose RTPs, while RTPs are available in the full analyses.

Changelog

  • Main change is the introduction of AnalysesManager. The analyses manager is responsible for creating a protocol analyzer per analysis, extracting the run time parameters from the runner and starting the analysis.
  • To facilitate this extraction of run time parameters, the ProtocolAnalyzer has been divided into two functions- one that loads the runner and other that runs the runner.
  • Updated the router to use AnalysesManager for starting analyses instead of directly interacting with ProtocolAnalyzer.

Review requests

  • Does the new architecture of AnalysesManager & updated ProtocolAnalyzer makes sense.
  • This PR doesn't expose the run time parameters in analysis summaries of completed analyses because of two reasons- (1) as opposed to the RTPs of a pending analysis, the completed analysis isn't guaranteed to be cached in memory. So we would need to read the completed analysis from database, de-serialize it and then return it. This would be made easier when we start storing RTPs in their own database table, but we're not there yet. (2) I'm not sure if it is needed. A completed analysis already contains the RTPs.
    Would like to get others' opinions on this.
  • Usual code review

Risk assessment

  • Medium. It changes a core part of protocol analysis but the end effect is a small change to the API. As long as tests are passing, it shouldn't cause any problems.
  • Small risk of analysis behavior change for badly written protocols as mentioned in this comment.

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.

Thank you! I know this is all a work in progress, but some suggestions so far:

robot-server/robot_server/protocols/router.py Outdated Show resolved Hide resolved
protocol_resource=protocol_resource,
run_time_param_values=parsed_rtp,
)
except BaseException as error:
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we want to catch Exception instead of BaseException. As a heuristic: if something raises KeyboardInterrupt or asyncio.CancelledError, we do not want to swallow it.

I see that the ProtocolAnalyzer internals are also currently catching BaseException. I think those should be catching Exception, too.

robot-server/robot_server/protocols/router.py Outdated Show resolved Hide resolved
@sanni-t sanni-t marked this pull request as ready for review June 6, 2024 04:41
@sanni-t sanni-t requested review from a team as code owners June 6, 2024 04:41
Copy link
Contributor

@jbleon95 jbleon95 left a comment

Choose a reason for hiding this comment

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

Changes look good and make sense to me, and will make adding the "new file needed" analysis result much easier

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.

yay ty

) -> None:
"""Initialize the analyzer and its dependencies."""
self._analysis_store = analysis_store
self._protocol_resource = protocol_resource

async def load_runner(
Copy link
Member Author

Choose a reason for hiding this comment

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

from discussion w/ @SyntaxColoring: making runner loading as a part of the analyzer initialization will help prevent misuse of load_runner(), for example, calling load_runner() multiple times.

I like this suggestion. Will take it into account when making the upcoming changes to the analysis arch.

@sanni-t sanni-t merged commit 6fb8adf into edge Jun 10, 2024
7 checks passed
@sanni-t sanni-t deleted the AUTH-282-show-rtps-in-pending-analysis branch June 10, 2024 16:21
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