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

✨ Is355/optimizer projects ports #3504

Merged

Conversation

pcrespov
Copy link
Member

@pcrespov pcrespov commented Nov 2, 2022

What do these changes do?

The PR extend the concept of ports of a service to a project: a project can now have input/output ports. The inputs can be read and updated and the latter can be read using the web API. The input ports in a project are defined by parameter nodes and the project outputs by probe nodes.

Highlights

  • webserver API updates to version 0.10.0
    • ✨defines new collections: GET/PATCH projects/{project_id}/inputs and GET projects/{project_id}/outputs: see project_ports_handlers.py
  • ♻️ models-library
    • updates fastapi_encoder
    • adds utils for service_io (will be used in catalog in coming PR)
  • 🔨api/specs/webserver/scripts/openapi_projects_ports.py helper scripts to produce OAS
  • 🔨 scripts to create ERD of pydantic models

Related issue/s

How to test

For manual testing (with swagger) :

  1. Create a project with parameters and probes. Name them nicely

image

  • three inputs in yellow: X, on and Z
  • three outputs in red Random sleep interval_2, Random sleep interval and Array probe
  • all inputs are connected
  • sleeper A has no results and sleeper B does
  • Array probe is disconnected
  1. Open swagger

image

  • get projects/{project_id}/inputs, patch projects/{project_id}/inputs
  • run projects/{project_id}
  • get projects/{project_id}/outputs

Checklist

  • validate input values against schema
  • make version-*
  • make openapi.json
  • cd packages/postgres-database, make setup-commit, sc-pg review -m "my changes"
  • Unit tests for the changes exist
  • Runs in the swarm
  • Documentation reflects the changes
  • New module? Add your github username to .github/CODEOWNERS

@pcrespov pcrespov self-assigned this Nov 2, 2022
@codecov
Copy link

codecov bot commented Nov 2, 2022

Codecov Report

Merging #3504 (bccd8cd) into master (e7eada1) will increase coverage by 0.1%.
The diff coverage is 79.7%.

Impacted file tree graph

@@           Coverage Diff            @@
##           master   #3504     +/-   ##
========================================
+ Coverage    83.4%   83.6%   +0.1%     
========================================
  Files         848     824     -24     
  Lines       35779   35376    -403     
  Branches      748     706     -42     
========================================
- Hits        29862   29588    -274     
+ Misses       5726    5603    -123     
+ Partials      191     185      -6     
Flag Coverage Δ
integrationtests 67.2% <46.6%> (-0.2%) ⬇️
unittests 80.6% <79.7%> (+0.1%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...ages/models-library/src/models_library/services.py 92.9% <ø> (ø)
...vice_webserver/projects/projects_nodes_handlers.py 79.3% <ø> (ø)
...models_library/utils/_original_fastapi_encoders.py 41.7% <41.7%> (ø)
...vice_webserver/projects/projects_ports_handlers.py 92.2% <92.2%> (ø)
...rary/src/servicelib/aiohttp/requests_validation.py 97.4% <92.3%> (-2.6%) ⬇️
...r/src/simcore_service_webserver/projects/_ports.py 93.5% <93.5%> (ø)
...ls-library/src/models_library/utils/services_io.py 95.4% <95.4%> (ø)
...brary/src/models_library/utils/fastapi_encoders.py 100.0% <100.0%> (+56.5%) ⬆️
...r/src/simcore_service_webserver/projects/plugin.py 100.0% <100.0%> (ø)
.../simcore_service_webserver/projects/projects_db.py 96.5% <100.0%> (+<0.1%) ⬆️
... and 34 more

@pcrespov pcrespov force-pushed the is355/optimizer-projects-ports branch from 56604a1 to fce73bc Compare November 4, 2022 23:15
@pcrespov pcrespov added this to the Katherine Switzer milestone Nov 5, 2022
@pcrespov pcrespov added the a:webserver issue related to the webserver service label Nov 5, 2022
@pcrespov pcrespov force-pushed the is355/optimizer-projects-ports branch from 55f5003 to b90aacf Compare November 7, 2022 20:09
@pcrespov pcrespov changed the title WIP: ✨ Is355/optimizer projects ports ✨ Is355/optimizer projects ports Nov 7, 2022
@pcrespov pcrespov force-pushed the is355/optimizer-projects-ports branch from 04c22dd to ac9ac96 Compare November 7, 2022 20:21
@pcrespov pcrespov marked this pull request as ready for review November 7, 2022 20:39
#

ARG PYTHON_VERSION="3.9.12"
FROM python:${PYTHON_VERSION}-slim-buster as base
Copy link
Member

Choose a reason for hiding this comment

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

sometimes I wonder if the non-slim version without installing 10 tools is not better than the slim version + 10 tools in term of size and build time.

Copy link
Member Author

Choose a reason for hiding this comment

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

yep. we could explore that. @mguidon showed me some tools we could use in the new HB registry. It might in addition help us decide more secure base images

Copy link
Member

@sanderegg sanderegg left a comment

Choose a reason for hiding this comment

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

Great work!

@mguidon
Copy link
Member

mguidon commented Nov 8, 2022

👍

@pcrespov pcrespov force-pushed the is355/optimizer-projects-ports branch from c5af8f6 to 1330a2a Compare November 8, 2022 08:31
Copy link
Contributor

@GitHK GitHK left a comment

Choose a reason for hiding this comment

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

So if I get this correctly the purpose of the PR, is to allow you to read and write input ports and read output ports.
Could you please add that in the description or body. It is not obvious.

Some comments and questions below

and node.key.startswith("simcore/services/frontend/parameter/")
and node.outputs
):
# invariants
Copy link
Contributor

Choose a reason for hiding this comment

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

This is not that helpful

Copy link
Member Author

Choose a reason for hiding this comment

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

I will add extra comments but i refer to a common programming term here: https://en.wikipedia.org/wiki/Invariant-based_programming

mock_catalog_service_api_responses: None,
expected: type[web.HTTPException],
):
"""This tests implements a minimal workflow to support the MVP
Copy link
Contributor

Choose a reason for hiding this comment

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

MVP stands for?

Copy link
Member Author

Choose a reason for hiding this comment

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

resp = await client.get(f"/v0/projects/{project_id}/outputs")
project_outputs, error = await assert_status(resp, expected_cls=expected)

if not error:
Copy link
Contributor

Choose a reason for hiding this comment

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

Why would there be an error here? if this is expected in some cases, please provide it as an expectation parameter to the test. I think this allows to better detect issues.

Copy link
Member Author

Choose a reason for hiding this comment

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

this is a technique we use a lot. The test parametrization adds a expected value with a status code that might be error or not. In the latter case, we perform some extra checks e.g. on the response

the expectation you refer is already checked in assert_status( resp, expected_cls=expected) . If expected is a non-error, then that assert function will make sure that error is None

@pcrespov pcrespov force-pushed the is355/optimizer-projects-ports branch from e7287f5 to a737c33 Compare November 8, 2022 15:23
@pcrespov pcrespov requested a review from GitHK November 8, 2022 15:25
Copy link
Contributor

@GitHK GitHK left a comment

Choose a reason for hiding this comment

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

👍

@pcrespov pcrespov force-pushed the is355/optimizer-projects-ports branch from 40d0175 to 69ca14b Compare November 9, 2022 00:44
@pcrespov pcrespov force-pushed the is355/optimizer-projects-ports branch from 69ca14b to bccd8cd Compare November 9, 2022 09:53
@sonarqubecloud
Copy link

sonarqubecloud bot commented Nov 9, 2022

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@pcrespov pcrespov merged commit 31ac97f into ITISFoundation:master Nov 9, 2022
@pcrespov pcrespov deleted the is355/optimizer-projects-ports branch November 9, 2022 10:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a:webserver issue related to the webserver service
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants