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

✨ web-api: ProjectGet model adds new permalinks field #4008

Merged
merged 27 commits into from
May 9, 2023

Conversation

pcrespov
Copy link
Member

@pcrespov pcrespov commented Mar 21, 2023

What do these changes do?

Preamble

A permalink is an url like https://osparc.io/study/{template_project_uuid} that when used in a browser it will copy the target template and open it as a standard project.

NOTE that for an unfortunate design decision (see #1975) https://osparc.io/#/study/{project_uuid} ( see # instead of /) is also defined in the front-end to open (not copy) a study BUT this is not considered in this definition of permalink .

NOTE also that there are some conditions for a study to have a permalink, e.g. it has to be a template.

Feature

In this PR ProjectGet schema in the API ( used in or as part of responses as GET /projects or GET /project/{project_id} ) adds a new optional field with permalink information:

permalink:
  title: ProjectPermalink
  required:
    - url
    - is_public
  type: object
  properties:
    url:
      title: Url
      maxLength: 2083
      minLength: 1
      type: string
      format: uri
    is_public:
      title: Is Public
      type: boolean

and example of data is

{
  {
     # ... 
    "dev": {},
    "permalink": {
      "url": "http://127.0.0.1:9081/study/43365f42-eb64-11ed-a1d1-02420a000016",
      "is_public": true
    }
  }
}

Implementation details

The implementation follows a design that decouples the part that creates the permalink (in the studies_dispatcher plugin) and the part that assigns the value in the ProjectGet model (in the projects plugin): the permalink field is computed using an external callback that is implemented in the studies_dispatcher plugin (who define permalinks) and is registered in the projects plugin (who exposes and defines the project resource) upon startup (see setup_studies_dispatcher).

Highlights

  • web-api version: 0.18.0 → 0.19.0
  • Note that permalink field in ProjectGet is optional: If for some reason it cannot be created, then it will not be returned. Some reasons could be:
    • the studies_dispatcher plugin is disabled: therefore even having a permalink no study will be dispatched
    • the study does not follow the criteria to be assigned a permalink (see PermalinkNotAllowedError)
      • example: Failed to create permalink: Can only create permalink from a template project. Got project_uuid='ee592535-99ff-515f-be2a-07c0f92c7a35' with project_type=<ProjectType.STANDARD: 'STANDARD'>
    • something else went wrong: better not to provide that provide an incorrect permalink

Related issue/s

How to test

  • create a standard project
    • GET /project/uuid should NOT include permalink
  • create a template and share with everyone
    • GET /project/uuid should include permalink

@pcrespov pcrespov self-assigned this Mar 21, 2023
@pcrespov pcrespov added the a:webserver issue related to the webserver service label Mar 21, 2023
@pcrespov pcrespov added this to the Mithril milestone Mar 21, 2023
@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.0% 0.0% Duplication

@codecov
Copy link

codecov bot commented Mar 21, 2023

Codecov Report

Merging #4008 (c86b6da) into master (8ebb2e3) will decrease coverage by 5.6%.
The diff coverage is 98.1%.

Impacted file tree graph

@@           Coverage Diff            @@
##           master   #4008     +/-   ##
========================================
- Coverage    85.5%   80.0%   -5.6%     
========================================
  Files         961     891     -70     
  Lines       41605   40235   -1370     
  Branches      953     822    -131     
========================================
- Hits        35599   32188   -3411     
- Misses       5789    7857   +2068     
+ Partials      217     190     -27     
Flag Coverage Δ
integrationtests 77.4% <ø> (+10.0%) ⬆️
unittests 79.0% <98.1%> (-3.4%) ⬇️

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

Impacted Files Coverage Δ
...c/servicelib/aiohttp/long_running_tasks/_server.py 89.5% <83.3%> (ø)
...c/simcore_service_webserver/projects/_permalink.py 97.5% <97.5%> (ø)
...ackages/models-library/src/models_library/users.py 100.0% <100.0%> (ø)
...imcore_service_webserver/projects/_create_utils.py 96.8% <100.0%> (+0.1%) ⬆️
...imcore_service_webserver/projects/_rest_schemas.py 100.0% <100.0%> (ø)
...rver/src/simcore_service_webserver/projects/api.py 100.0% <100.0%> (ø)
..._service_webserver/projects/projects_exceptions.py 84.3% <100.0%> (-9.4%) ⬇️
...rvice_webserver/projects/projects_handlers_crud.py 87.5% <100.0%> (-0.4%) ⬇️
...bserver/studies_dispatcher/_projects_permalinks.py 100.0% <100.0%> (ø)
...ore_service_webserver/studies_dispatcher/plugin.py 100.0% <100.0%> (ø)

... and 210 files with indirect coverage changes

@sanderegg sanderegg modified the milestones: Mithril, The Next Milestone Mar 31, 2023
@pcrespov pcrespov modified the milestones: Jelly Beans, PastelDeNata May 4, 2023
@pcrespov pcrespov force-pushed the is829/get-project-permalink branch 5 times, most recently from 167a34d to 3acc8db Compare May 5, 2023 17:35
@pcrespov pcrespov changed the title WIP: ✨ adds functionality to compute permalinks ✨ adds functionality to compute permalinks May 5, 2023
@pcrespov pcrespov marked this pull request as ready for review May 5, 2023 17:35
@pcrespov pcrespov changed the title ✨ adds functionality to compute permalinks ✨ ProjectGet model includes permalinks field May 5, 2023
@pcrespov pcrespov requested a review from odeimaiz May 5, 2023 17:45
@pcrespov pcrespov changed the title ✨ ProjectGet model includes permalinks field ✨ web-api: ProjectGet model adds new permalinks field May 5, 2023
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! a few minor comments.

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! a few minor comments.

@pcrespov pcrespov force-pushed the is829/get-project-permalink branch from c6575ba to 724e153 Compare May 8, 2023 08:02
@pcrespov pcrespov requested a review from GitHK May 8, 2023 08:03
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 enabled auto-merge (squash) May 8, 2023 09:27
@pcrespov pcrespov disabled auto-merge May 9, 2023 08:49
@pcrespov pcrespov enabled auto-merge (squash) May 9, 2023 08:49
@codeclimate
Copy link

codeclimate bot commented May 9, 2023

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

View more on Code Climate.

@sonarqubecloud
Copy link

sonarqubecloud bot commented May 9, 2023

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.6% 0.6% Duplication

@pcrespov pcrespov merged commit a7ab0fb into ITISFoundation:master May 9, 2023
@pcrespov pcrespov deleted the is829/get-project-permalink branch May 9, 2023 18:51
@pcrespov pcrespov changed the title ✨ web-api: ProjectGet model adds new permalinks field ✨ web-api: ProjectGet model adds new permalinks field 🚨 May 9, 2023
@pcrespov
Copy link
Member Author

pcrespov commented May 9, 2023

🚨

  • test in master (see "How to test" section)

@pcrespov pcrespov changed the title ✨ web-api: ProjectGet model adds new permalinks field 🚨 ✨ web-api: ProjectGet model adds new permalinks field May 10, 2023
@matusdrobuliak66 matusdrobuliak66 mentioned this pull request May 30, 2023
24 tasks
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.

Link to share templates
5 participants