Skip to content

Feature export/import study (backend) #2053

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

Merged
merged 147 commits into from
Jan 21, 2021
Merged
Show file tree
Hide file tree
Changes from 135 commits
Commits
Show all changes
147 commits
Select commit Hold shift + click to select a range
731cdc9
adding module
Dec 14, 2020
4ecfb20
first basic version which exports
Dec 15, 2020
36cded7
Merge branch 'master' into feature-export-import
GitHK Dec 15, 2020
86b2474
added openapi spec for import, still wip
Dec 15, 2020
5d7b455
Merge branch 'feature-export-import' of github.com:GitHK/osparc-simco…
Dec 15, 2020
4b23146
first version of the full download
Dec 16, 2020
0311a7f
installed parfive [still not sure about this one]
Dec 16, 2020
cf3e7df
moved dat to yaml
Dec 16, 2020
e1f3a66
changed export format
Dec 16, 2020
741d6e6
Merge branch 'master' into feature-export-import
GitHK Dec 17, 2020
4589f92
Merge branch 'feature-export-import' of github.com:GitHK/osparc-simco…
Dec 17, 2020
12dbcca
correctly updated dependencies
Dec 17, 2020
9ee370d
Merge branch 'master' into feature-export-import
GitHK Dec 17, 2020
e39394a
updated openapi spec
Dec 17, 2020
81ddef1
added support for uploading osparcprojects
Dec 17, 2020
9b46e84
added upload endpoint
Dec 17, 2020
84c34b8
Merge branch 'feature-export-import' of github.com:GitHK/osparc-simco…
Dec 17, 2020
7a81d9a
upgraded parfive and refavtored code
Dec 18, 2020
bf36c79
reverting to former implementation
Dec 18, 2020
4ddf60e
reverted version as well
Dec 18, 2020
4454811
export now saves all files from storage
Dec 21, 2020
30b74d9
added max_upload_size to 10 GB default
Dec 21, 2020
730574c
added defaults for local env
Dec 21, 2020
a7974c9
Merge branch 'master' into feature-export-import
GitHK Dec 21, 2020
7069fcc
removed unused
Dec 21, 2020
92b5d7a
refactored importers into formatters
Dec 21, 2020
d2e59d2
Merge branch 'master' into feature-export-import
GitHK Dec 22, 2020
e50edd6
refactored code to use formatters and models
Dec 23, 2020
048f793
Merge branch 'master' into feature-export-import
GitHK Dec 23, 2020
3a68673
refactored code structure
Dec 23, 2020
6ac2bfa
moved LinkAndFile to Pydantic model
Dec 23, 2020
92dfdc3
split storge from relative file path
Dec 23, 2020
2d52303
added data shuffling to project data and files
Dec 23, 2020
6f4b94d
renamed models to avoid confusion
Dec 23, 2020
b7a1fda
refactored from classmethod
Dec 23, 2020
22702ea
Merge branch 'master' into feature-export-import
GitHK Dec 24, 2020
73d0911
Merge branch 'feature-export-import' of github.com:GitHK/osparc-simco…
Dec 24, 2020
7a61892
changed data types to allow for import/export of projects
Dec 24, 2020
19de0f1
first startable project after export/import
Dec 24, 2020
a0412ce
pylint: imports and params cleanup
Dec 24, 2020
299adef
fixed codeclimate
Dec 24, 2020
9ddce14
trying to bypass codeclimate
Dec 24, 2020
69cd39d
fix pylint
Jan 4, 2021
c736b7f
exporter
Jan 4, 2021
07e6eb5
put back temp dir removal
Jan 4, 2021
2720691
importing a project also creates its files
Jan 4, 2021
152d747
added failing test which is skipped
Jan 7, 2021
95bb9e8
found a way to bypass py38 requirement
Jan 8, 2021
70bbcbf
wait for all services in simcore
Jan 8, 2021
fa6e4aa
reverting change back
Jan 8, 2021
1b919e1
fixes issue with thumbnails
Jan 8, 2021
d1fd4c6
Merge branch 'master' into feature-export-import
GitHK Jan 8, 2021
435501b
trying to tix schema
Jan 8, 2021
f077a5f
adminer is not used
Jan 8, 2021
49715bb
when directorv0 had an issue, there were several errors
Jan 8, 2021
fc73d9b
fixed error
Jan 8, 2021
03454c5
the imported project uuid is returned
Jan 8, 2021
6c0a44f
must upgrade parfive after python upgrade
Jan 8, 2021
2722521
removed unecessary request and used app instead
Jan 8, 2021
6026159
if an error occurs during import a rollback is done
Jan 8, 2021
460aa03
replaced test export V1; thumbnail format changed
Jan 8, 2021
270f7a3
removed adminer
Jan 8, 2021
df39f67
changed project data files to json
Jan 8, 2021
193234a
renamed module
Jan 8, 2021
407314f
renamed function
Jan 8, 2021
fb08a5e
removed comment
Jan 8, 2021
229f045
updated docstring
Jan 8, 2021
87dac8c
added more checks wen files are downloed from storage
Jan 8, 2021
182e84d
codeclimate is anoying
Jan 8, 2021
bdeeee5
removed redoundant checks
Jan 8, 2021
eb7bbcd
minor refactoring
Jan 8, 2021
5c1cb99
major refactor
Jan 8, 2021
40e67c7
refactored and cleared up information
Jan 8, 2021
20016b1
format changed
Jan 11, 2021
6e8d909
Merge remote-tracking branch 'upstream/master' into feature-export-im…
Jan 12, 2021
dc2662c
more logging for easier debugging
Jan 12, 2021
4ab29ad
replaced format again
Jan 12, 2021
fe85640
got half of the test to work proerly
Jan 12, 2021
fac55b7
added compressed version to test
Jan 12, 2021
0e4d3ef
import export test finalized
Jan 12, 2021
b430664
added comment to clarifay extra str type
Jan 13, 2021
543a27b
changed import path to google api spec
Jan 13, 2021
1378e76
wrapping exporter errors so they can be centralized
Jan 13, 2021
ef0a200
mode refactor
Jan 13, 2021
2c02870
updated and fixed confusing comments
Jan 13, 2021
7978188
Update services/web/server/src/simcore_service_webserver/exporter/exp…
GitHK Jan 13, 2021
bdbf8d3
updated confusing parfive message
Jan 13, 2021
d5ccbe9
parfive aiofiles support message fixed
Jan 13, 2021
fba4a3e
await on all uplaods in parallel
Jan 13, 2021
cf20e5b
updated type
Jan 13, 2021
26cc416
semplified project structure
Jan 13, 2021
ac9beff
updated export import format of files
Jan 13, 2021
df38a85
remove outdated comments
Jan 13, 2021
c1fdbd9
fixed circular dependency import
Jan 13, 2021
05e9969
refactored imports
Jan 13, 2021
0e88c20
Merge branch 'feature-export-import' of github.com:GitHK/osparc-simco…
Jan 13, 2021
8530e54
refactored hwo responses are handled
Jan 13, 2021
af9e56b
fixed pylint
Jan 13, 2021
31ce875
fixed logic style
Jan 13, 2021
f557e72
removed dependency on studies_dispatcher mdoule
Jan 13, 2021
4bfb98e
Merge branch 'master' into feature-export-import
GitHK Jan 13, 2021
67e0b7c
Merge branch 'feature-export-import' of github.com:GitHK/osparc-simco…
Jan 13, 2021
7ac04d7
added missing type
Jan 13, 2021
bce4be8
file might not exist
Jan 13, 2021
ceadd8e
archiving module 100 test coverage
Jan 13, 2021
f592644
Merge branch 'master' into feature-export-import
GitHK Jan 13, 2021
5ca6da1
reverting change as it breaks the comp pipelines
Jan 14, 2021
c139a05
added export and import permissions
Jan 14, 2021
c7fb121
Merge branch 'feature-export-import' of github.com:GitHK/osparc-simco…
Jan 14, 2021
17b652a
refactored to semplify
Jan 14, 2021
6d786c8
refactored type
Jan 14, 2021
02d5d3d
in case of errors
Jan 14, 2021
ab10ac9
added comments to clear up how the export works
Jan 14, 2021
8eee2cd
trying to fix codeclimate
Jan 14, 2021
2b6bef2
patching for ptsv debug
Jan 14, 2021
a369072
archiving is now done via shutil
Jan 14, 2021
4e8a427
pyyaml is required by other modules
Jan 14, 2021
58f2a5f
returned as before
Jan 14, 2021
45d002d
fix pylint
Jan 14, 2021
509ce91
compression can no longer be disabled
Jan 14, 2021
ae5a6dc
fixing to comply to codeclimante rules
Jan 14, 2021
071bf92
only the compressed version is now supported
Jan 14, 2021
e8d1a4d
fixed openapi specs
Jan 14, 2021
f1c21f2
there is an issue respecting the google spec
Jan 14, 2021
48d46c3
fuxed type of error raised
Jan 14, 2021
0867164
replaced exceptons with ExporterException
Jan 14, 2021
c29829d
Merge branch 'master' into feature-export-import
sanderegg Jan 19, 2021
3c2f779
Merge branch 'master' into feature-export-import
GitHK Jan 19, 2021
de9bf94
fix comment
Jan 19, 2021
e5d3e8b
minor refactor
Jan 19, 2021
c99301a
export is now POST no longer get
Jan 19, 2021
0610d73
ensuring correct propagation of CancelledError
Jan 19, 2021
a5fb061
logging as warning
Jan 19, 2021
df93ae3
downloader timeout bumped to 1h max
Jan 19, 2021
9f4b737
migrated constant to configration
Jan 19, 2021
9a108bc
refactored exporter config to use Pydantic
Jan 20, 2021
290ad17
removed section which no longer exists
Jan 20, 2021
26b4cb8
updated docstring
Jan 20, 2021
2791180
fixed test
Jan 20, 2021
dff07e8
Merge branch 'master' into feature-export-import
GitHK Jan 20, 2021
1307311
Merge branch 'master' into feature-export-import
GitHK Jan 20, 2021
b57007e
Merge branch 'master' into feature-export-import
GitHK Jan 20, 2021
c0d9117
migrated configuration to Pydantic and decoupled module
Jan 21, 2021
3649de5
Merge branch 'master' into feature-export-import
GitHK Jan 21, 2021
c431fa2
adding back missing module
Jan 21, 2021
40c3ad9
making setup function detectable in testing
Jan 21, 2021
761a7af
added missing section
Jan 21, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .env-devel
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ WEBSERVER_PROMETHEUS_PORT=9090
WEBSERVER_PROMETHEUS_API_VERSION=v1
WEBSERVER_RESOURCES_DELETION_TIMEOUT_SECONDS=900
WEBSERVER_GARBAGE_COLLECTION_INTERVAL_SECONDS=30
WEBSERVER_MAX_UPLOAD_FILE_SIZE_GB=10
WEBSERVER_MANUAL_MAIN_URL=http://docs.osparc.io/
WEBSERVER_MANUAL_EXTRA_URL=https://itisfoundation.github.io/osparc-manual-z43/
WEBSERVER_FOGBUGZ_LOGIN_URL=https://z43.manuscript.com/login
Expand Down
54 changes: 54 additions & 0 deletions api/specs/webserver/openapi-projects.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,60 @@ paths:
default:
$ref: "#/components/responses/DefaultErrorResponse"

/projects/{project_id}/export:
parameters:
- name: project_id
in: path
required: true
schema:
type: string
- name: compressed
in: query
required: false
schema:
type: boolean
post:
tags:
- project
summary: creates an archive of the project and downloads it
operationId: export_project
responses:
"200":
description: creates an archive from a project file
content:
application/zip:
schema:
type: string
format: binary
default:
$ref: "#/components/responses/DefaultErrorResponse"

/projects/import:
post:
tags:
- project
summary: Create new project from an archive
operationId: import_project
requestBody:
content:
multipart/form-data:
schema:
type: object
properties:
fileName:
type: string
format: binary
responses:
"201":
description: creates a new project from an archive
content:
application/json:
schema:
#TODO: change this with an OK response
$ref: "#/components/schemas/ProjectEnveloped"
default:
$ref: "#/components/responses/DefaultErrorResponse"

/projects/{project_id}/close:
parameters:
- name: project_id
Expand Down
8 changes: 7 additions & 1 deletion api/specs/webserver/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@ paths:
/groups/sparc/classifiers/scicrunch-resources:search:
$ref: "./openapi-groups.yaml#/paths/~1groups~1sparc~1classifiers~1scicrunch-resources:search"


# DATA STORAGE SERVICES ----------------------------------------------------------

/storage/locations:
Expand Down Expand Up @@ -169,6 +168,13 @@ paths:
/projects/{project_id}/state:
$ref: "./openapi-projects.yaml#/paths/~1projects~1{project_id}~1state"

# FIXME: /projects/{project_id}:export dose not work
/projects/{project_id}/export:
$ref: "./openapi-projects.yaml#/paths/~1projects~1{project_id}~1export"

/projects:import:
$ref: "./openapi-projects.yaml#/paths/~1projects~1import"

Comment on lines +172 to +177
Copy link
Member

Choose a reason for hiding this comment

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

it's here you need to have the :. all the others should be using /

see for an example the /projects/{project_id}:open endpoint

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm trying to get this to work as you said but had no success with it.
I've tried to follow the exact same pattern, but had no success with it.
It replies with an error like uuid:open dose not exist. It interprets :open as part of the parameter.

/projects/{project_id}:close:
$ref: "./openapi-projects.yaml#/paths/~1projects~1{project_id}~1close"

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from enum import Enum

from pydantic import conint, constr, confloat
from pydantic import confloat, conint, constr

PortInt = conint(gt=0, lt=65535)

Expand Down
19 changes: 13 additions & 6 deletions packages/models-library/src/models_library/projects.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
Models a study's project document
"""
from copy import deepcopy
from typing import Dict, List, Optional, Any
from typing import Any, Dict, List, Optional, Union
from uuid import UUID

from pydantic import BaseModel, EmailStr, Extra, Field, HttpUrl
from pydantic import BaseModel, EmailStr, Extra, Field, HttpUrl, validator

from .basic_regex import DATE_RE
from .projects_access import AccessRights, GroupID
Expand Down Expand Up @@ -40,7 +40,9 @@ class Project(BaseModel):
description="longer one-line description about the project",
examples=["Dabbling in temporal transitions ..."],
)
thumbnail: HttpUrl = Field(
# NOTE: str is necessary because HttpUrl will not accept and empty string and the
# frontend sometimes sends this empty string, which is removed by the validator
thumbnail: Union[str, HttpUrl] = Field(
...,
description="url of the project thumbnail",
examples=["https://placeimg.com/171/96/tech/grayscale/?0.jpg"],
Expand Down Expand Up @@ -88,9 +90,14 @@ class Project(BaseModel):
quality: Dict[str, Any] = {}

# Dev only
dev: Optional[Dict] = Field(
description="object used for development purposes only"
)
dev: Optional[Dict] = Field(description="object used for development purposes only")

@classmethod
@validator("thumbnail")
def null_thumbnail(cls, v):
if isinstance(v, str) and v == "":
return None
return v

class Config:
description = "Document that stores metadata, pipeline and UI setup of a study"
Expand Down
3 changes: 3 additions & 0 deletions packages/service-library/src/servicelib/rest_middlewares.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,9 @@ async def _middleware_handler(request: web.Request, handler):

resp = await handler(request)

if isinstance(resp, web.FileResponse): # allows for files to be downloaded
return resp

if not isinstance(resp, web.Response):
response = create_data_response(
data=resp, skip_internal_error_details=_is_prod,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ async def wrapper_func(*args, **kwargs) -> httpx.Response:
service_name,
resp.reason_phrase,
resp.status_code,
resp.text(),
resp.text,
)
raise HTTPException(status.HTTP_503_SERVICE_UNAVAILABLE)

Expand Down
1 change: 1 addition & 0 deletions services/web/server/requirements/_base.in
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,6 @@ python-socketio
semantic_version
aiodebug
json2html
parfive

pydantic[email]
2 changes: 2 additions & 0 deletions services/web/server/requirements/_base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ multidict==4.7.6 # via aiohttp, yarl
openapi-core==0.12.0 # via -r requirements/../../../../packages/service-library/requirements/_base.in
openapi-spec-validator==0.2.9 # via openapi-core
pamqp==2.3.0 # via aiormq
parfive==1.0.2 # via -r requirements/_base.in
passlib==1.7.2 # via -r requirements/_base.in
prometheus-client==0.9.0 # via -r requirements/../../../../packages/service-library/requirements/_base.in
prompt-toolkit==3.0.8 # via click-repl
Expand All @@ -68,6 +69,7 @@ six==1.15.0 # via click-repl, cryptography, isodate, jsonschema, o
sqlalchemy[postgresql_psycopg2binary]==1.3.20 # via -c requirements/../../../../packages/models-library/requirements/../../../requirements/constraints.txt, -c requirements/../../../../packages/postgres-database/requirements/../../../requirements/constraints.txt, -c requirements/../../../../packages/service-library/requirements/../../../requirements/constraints.txt, -c requirements/../../../../requirements/constraints.txt, -r requirements/../../../../packages/postgres-database/requirements/_base.in, -r requirements/../../../../packages/service-library/requirements/_base.in, aiopg
strict-rfc3339==0.7 # via openapi-core
tenacity==6.2.0 # via -r requirements/../../../../packages/service-library/requirements/_base.in
tqdm==4.54.1 # via parfive
trafaret==2.0.2 # via -r requirements/../../../../packages/service-library/requirements/_base.in
typing-extensions==3.7.4.2 # via aiohttp, yarl
ujson==3.1.0 # via -r requirements/../../../../packages/service-library/requirements/_base.in, aiohttp-swagger
Expand Down
Loading