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

Support "x_unit": unit conversions, ranges and validation #2894

Merged
merged 43 commits into from
Mar 22, 2022

Conversation

odeimaiz
Copy link
Member

@odeimaiz odeimaiz commented Mar 15, 2022

What do these changes do?

BackEnd:

  • Entry inputsUnits added to project schema and model: project:workbench:{nodeId}:inputsUnits

FrontEnd:

  • Hardcode some units info based on Pint unit library
  • Render x_unit in inputs field (updateble): short label (µs, km) in field and long label (microsecond, kilometer) in tooltip
  • Render x_unit in outputs field (non updatable): short label (µs, km) in field and long label (microsecond, kilometer) in tooltip
  • Users can change the unit prefix by clicking on the unit field
  • When the user clicks on the unit field:
    • Prefix is updated
    • Value is updated
    • Field constraints are updated
  • Serialize units that differ from the schema in inputsUnits
  • Deserialize units coming in inputsUnits
  • When serializing a project, inputs are converted back to the unit specified in schema
  • When deserializing a project, inputs are converted to the unit specified in inputsUnits
  • If the service provides a minimum/maximum value for an input field, they are validated in the frontend.

DemoUnits

Inputs from Demo Units service more:
image

Related issue/s

Related to ITISFoundation/osparc-issues#515

How to test

Checklist

@odeimaiz odeimaiz added this to the E.Shackleton milestone Mar 15, 2022
@odeimaiz odeimaiz self-assigned this Mar 15, 2022
@codecov
Copy link

codecov bot commented Mar 16, 2022

Codecov Report

Merging #2894 (88d53eb) into master (60e462a) will increase coverage by 6.2%.
The diff coverage is 100.0%.

Impacted file tree graph

@@           Coverage Diff            @@
##           master   #2894     +/-   ##
========================================
+ Coverage    73.1%   79.3%   +6.2%     
========================================
  Files         551     671    +120     
  Lines       23736   27613   +3877     
  Branches     2626    3223    +597     
========================================
+ Hits        17365   21923   +4558     
+ Misses       5702    4941    -761     
- Partials      669     749     +80     
Flag Coverage Δ
integrationtests 65.7% <ø> (-0.1%) ⬇️
unittests 75.0% <100.0%> (+7.4%) ⬆️

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

Impacted Files Coverage Δ
...e_api_server/utils/solver_job_models_converters.py 86.4% <ø> (ø)
.../src/models_library/function_service/demo_units.py 100.0% <100.0%> (ø)
...odels-library/src/models_library/projects_nodes.py 95.5% <100.0%> (ø)
...rvice_datcore_adapter/utils/requests_decorators.py 71.0% <0.0%> (-7.9%) ⬇️
...ore_service_director_v2/utils/dask_client_utils.py 73.4% <0.0%> (-1.3%) ⬇️
...tor_v2/modules/dynamic_sidecar/scheduler/events.py 93.7% <0.0%> (-1.2%) ⬇️
...ector_v2/modules/dynamic_sidecar/scheduler/task.py 86.0% <0.0%> (-0.5%) ⬇️
...ings-library/src/settings_library/utils_service.py 95.0% <0.0%> (ø)
...ice-library/src/servicelib/fastapi/dependencies.py 0.0% <0.0%> (ø)
...ages/models-library/src/models_library/generics.py 91.8% <0.0%> (ø)
... and 208 more

@odeimaiz odeimaiz changed the title WIP: x_unit to gui WIP: Support x_unit: unit conversions, ranges and validation Mar 17, 2022
@odeimaiz odeimaiz changed the title WIP: Support x_unit: unit conversions, ranges and validation WIP: Support "x_unit": unit conversions, ranges and validation Mar 17, 2022
@odeimaiz odeimaiz added the a:frontend issue affecting the front-end (area group) label Mar 17, 2022
@odeimaiz odeimaiz marked this pull request as ready for review March 18, 2022 20:08
@odeimaiz odeimaiz changed the title WIP: Support "x_unit": unit conversions, ranges and validation Support "x_unit": unit conversions, ranges and validation Mar 18, 2022
Copy link
Member

@pcrespov pcrespov left a comment

Choose a reason for hiding this comment

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

I assume that this PR will only introduce units for single-type values i.e. not objects or lists (that comes in another PR?).

@odeimaiz
Copy link
Member Author

I assume that this PR will only introduce units for single-type values i.e. not objects or lists (that comes in another PR?).

Exactly, since the input values do not support objects, I didn't see the point on supporting them in the units. Let's discuss it offline.

@sanderegg sanderegg self-requested a review March 21, 2022 14:57
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.

pair reviewed, great!

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.

Fine with me, nothing to add.

@KZzizzle
Copy link
Contributor

very nice!!

@pcrespov pcrespov merged commit e2f5e16 into ITISFoundation:master Mar 22, 2022
@odeimaiz odeimaiz deleted the feature/x-unit-to-gui branch April 21, 2022 11:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a:frontend issue affecting the front-end (area group)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants