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

dynamic-sidecar saves and restores user services preferences #4779

Merged

Conversation

GitHK
Copy link
Contributor

@GitHK GitHK commented Sep 20, 2023

What do these changes do?

Allows user services to store data per user and per product globally. A folder, thaw when zipped is at most 128kb, is made available for storing data.

NOTE 1: this limit can be raised BUT NEVER LOWERED after this is merged. We can end up in validation errors and services not starting. Complain now about the size being too large!!
NOTE 2: The data is stored in Postgres!

What happens if the version of my service is upgraded. Well consider the following scenarios:

  • 1.2.3 -> 1.2.3 get the same
  • 1.2.3 -> 1.2.1 get the same (despite the older version, the service owner has to deal with this)
  • 1.2.3 -> 1.2.4 get the same
  • 1.2.3 -> 1.1.0 new one
  • 1.2.3 -> 1.3.0 new one
  • 1.2.3 -> 2.0.0 new one

TL;DR: we only store the preferences under major.minior, patch is discarted!


The feature is disabled by default and user services can ask for it by extending their specification.

In the user service's runtime.yaml add the following:

user-preferences-path: /path/to/some-user-preferences

NOTE versions starting from itisfoundation/ci-service-integration-library:v1.0.3-dev-4 and up support this feature

Extras:

Related issue/s

How to test

DevOps Checklist

@codecov
Copy link

codecov bot commented Sep 20, 2023

Codecov Report

Merging #4779 (2221532) into master (4f3bac3) will decrease coverage by 1.5%.
The diff coverage is 90.9%.

Impacted file tree graph

@@           Coverage Diff            @@
##           master   #4779     +/-   ##
========================================
- Coverage    86.5%   85.0%   -1.5%     
========================================
  Files        1169    1072     -97     
  Lines       48609   46724   -1885     
  Branches     1060     881    -179     
========================================
- Hits        42051   39742   -2309     
- Misses       6324    6785    +461     
+ Partials      234     197     -37     
Flag Coverage Δ
integrationtests 63.8% <87.0%> (-1.2%) ⬇️
unittests 84.6% <76.5%> (+<0.1%) ⬆️

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

Files Coverage Δ
...api_schemas_directorv2/dynamic_services_service.py 97.1% <100.0%> (-0.1%) ⬇️
...els-library/src/models_library/user_preferences.py 90.7% <100.0%> (-0.4%) ⬇️
...tegration/src/service_integration/osparc_config.py 87.6% <100.0%> (+<0.1%) ⬆️
...imcore_service_dynamic_sidecar/core/application.py 97.1% <100.0%> (+<0.1%) ⬆️
...c/simcore_service_dynamic_sidecar/core/settings.py 96.9% <100.0%> (+0.3%) ⬆️
...ecar/modules/user_services_preferences/__init__.py 100.0% <100.0%> (ø)
...c_sidecar/modules/user_services_preferences/_db.py 100.0% <100.0%> (ø)
...decar/modules/user_services_preferences/_errors.py 100.0% <100.0%> (ø)
...ar/modules/user_services_preferences/_packaging.py 100.0% <100.0%> (ø)
...idecar/modules/user_services_preferences/_setup.py 100.0% <100.0%> (ø)
... and 12 more

... and 176 files with indirect coverage changes

@GitHK GitHK self-assigned this Sep 22, 2023
@GitHK
Copy link
Contributor Author

GitHK commented Sep 27, 2023

Q1: What will be the use case for this? what kind of data will the user store there? thx.

When using a service like jupyter-math, let's say you want the theme to be stored globally for all the future ones you open. You always want to be dark. This way you can save the setting in one of them and when adding a new one you don't have to set the theme back again.

Q2: Do I understand correctly that user + product combination will occupy at max 128kb space in DB?

Well actually user + product + key + major+ minor. An entry like: (1, "osparc", "simcore/services/math", "1.2"). So you will have on average 1 per user per service. And the service must request this feature. In reality there will be at most 1 or 2 entries per user since only one service, for now requires this.
The 128kb, is the max size of this zipped preferences folder.

@GitHK
Copy link
Contributor Author

GitHK commented Sep 27, 2023

@matusdrobuliak66

Q1: What will be the use case for this? what kind of data will the user store there? thx.

When using a service like jupyter-math, let's say you want the theme to be stored globally for all the future ones you open. You always want to be dark. This way you can save the setting in one of them and when adding a new one you don't have to set the theme back again.

Q2: Do I understand correctly that user + product combination will occupy at max 128kb space in DB?

Well actually user + product + key + major+ minor. An entry like: (1, "osparc", "simcore/services/math", "1.2"). So you will have on average 1 per user per service. And the service must request this feature. In reality there will be at most 1 or 2 entries per user since only one service, for now requires this. The 128kb, is the max size of this zipped preferences folder.

@GitHK GitHK requested a review from pcrespov September 27, 2023 06:53
@GitHK GitHK requested a review from pcrespov October 9, 2023 09:04
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.

Thx. Please check the notes before merging. Otherwise go ahead.

@codeclimate
Copy link

codeclimate bot commented Oct 11, 2023

Code Climate has analyzed commit 2221532 and detected 0 issues on this pull request.

View more on Code Climate.

@sonarqubecloud
Copy link

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.1% 0.1% Duplication

@GitHK GitHK enabled auto-merge (squash) October 11, 2023 07:27
@GitHK GitHK merged commit e160446 into ITISFoundation:master Oct 11, 2023
@GitHK GitHK deleted the pr-osparc-add-preferences-user-services branch October 11, 2023 07:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a:director-v2 issue related with the director-v2 service a:dynamic-sidecar dynamic-sidecar service
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants