Skip to content

Nodeports/add file checksum #2011

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 74 commits into from
Dec 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
74 commits
Select commit Hold shift + click to select a range
61d983a
ensure storage is in debug mode when in devel
sanderegg Nov 29, 2020
13f3f2c
format
sanderegg Nov 30, 2020
e624fc2
missing alembic
sanderegg Nov 30, 2020
4410e61
added pytest-black
sanderegg Nov 30, 2020
f5e09e3
formatting
sanderegg Nov 30, 2020
266e771
added annotations
sanderegg Nov 30, 2020
a854b5c
repair merge
sanderegg Nov 30, 2020
6299a11
missing alembic for testing
sanderegg Nov 30, 2020
32f739c
set back minio
sanderegg Nov 30, 2020
cfc2e98
Squashed commit of the following:
sanderegg Dec 3, 2020
6a1d7b9
add some unit tests
sanderegg Dec 3, 2020
ddc1fd2
more unit tests
sanderegg Dec 3, 2020
ee429bb
improve types
sanderegg Dec 3, 2020
7a960ef
use pydantic with email validator
sanderegg Dec 3, 2020
27fbeba
re-use classes from models library
sanderegg Dec 3, 2020
c09e739
use model library as base
sanderegg Dec 3, 2020
17647b6
fix uuid
sanderegg Dec 3, 2020
1376d12
PortLink without UUID
sanderegg Dec 3, 2020
b78d1d8
adjust test
sanderegg Dec 3, 2020
ef3ffc1
test possible port options
sanderegg Dec 4, 2020
b2df427
test port options
sanderegg Dec 4, 2020
06466d5
correctly check value in port validation
sanderegg Dec 4, 2020
5fbdad8
unit tests getting better, using fake storage calls
sanderegg Dec 4, 2020
206eb38
testing download links as well
sanderegg Dec 4, 2020
7d023b6
check portlink
sanderegg Dec 4, 2020
6509f4d
improve verbosity
sanderegg Dec 4, 2020
d377702
linter
sanderegg Dec 4, 2020
5ce66e4
getting there with unit testing port
sanderegg Dec 4, 2020
e4c1494
last check before running out of the train
sanderegg Dec 4, 2020
0b40a7d
Port fully tested
sanderegg Dec 4, 2020
5bc9747
create new file
sanderegg Dec 4, 2020
c3d06c3
fixed mocking of download data
sanderegg Dec 5, 2020
49d44fc
fix file to key map
sanderegg Dec 5, 2020
73580e7
ensure if a file is already there it does not create issues
sanderegg Dec 5, 2020
5540642
adding test of port mapping
sanderegg Dec 5, 2020
08e4378
add some typical coveragerc definitions
sanderegg Dec 7, 2020
128066a
use trick to use fixtures inside parametrization
sanderegg Dec 7, 2020
f2bef9b
100% test on port_mapping
sanderegg Dec 7, 2020
f62e78e
move fixtures to base conftest
sanderegg Dec 7, 2020
2e5f4c6
tests refactor
sanderegg Dec 7, 2020
7b36c14
tests serialization2
sanderegg Dec 7, 2020
43f7cbc
not far from 100%
sanderegg Dec 7, 2020
44a9f42
cleanup
sanderegg Dec 7, 2020
cd87fb2
remove unused version
sanderegg Dec 7, 2020
3fcb3cb
added standard package testing, linter
sanderegg Dec 7, 2020
e02039c
linter
sanderegg Dec 7, 2020
c2c7b47
mypy
sanderegg Dec 7, 2020
8294c70
improve testing
sanderegg Dec 7, 2020
a5f9434
add ETag
sanderegg Dec 7, 2020
c0500fe
added ETag when uploading file
sanderegg Dec 8, 2020
6420568
fix test related to uploaded file and received eTag
sanderegg Dec 8, 2020
160fd04
cleaning up
sanderegg Dec 8, 2020
f910562
add eTag into project json schema
sanderegg Dec 8, 2020
32a65f2
bonus: fix progress already in percent
sanderegg Dec 8, 2020
04a82a1
switch sidecar to node ports v2
sanderegg Dec 8, 2020
e1a3703
add tqdm to time download
sanderegg Dec 8, 2020
3825467
time download upload using tqdm
sanderegg Dec 8, 2020
c0124df
linter
sanderegg Dec 8, 2020
208d1a5
add bumpversion needed files
sanderegg Dec 8, 2020
c1cce6a
bumped version to 0.3.0
sanderegg Dec 8, 2020
36473c9
fix bad merge
sanderegg Dec 9, 2020
70814a2
@pcrespov review: add deprecation warnings
sanderegg Dec 9, 2020
a64afa4
@pcrespov review: remove unnecessary exclusion
sanderegg Dec 9, 2020
c166688
@pcrespov review: rename mock fixtures from subsystem to service
sanderegg Dec 9, 2020
5136eda
@pcrespov review: missing comments
sanderegg Dec 9, 2020
8043977
@pcrespov review: use dump/load names
sanderegg Dec 9, 2020
031c322
@pcrespov review: typo
sanderegg Dec 9, 2020
7aa4361
@GitHK review: remove useless return
sanderegg Dec 9, 2020
ec4601a
@GitHK review: check if while reading something bad happens
sanderegg Dec 9, 2020
0dbe66f
@GitHK review: re-enabling assertion
sanderegg Dec 9, 2020
7295f33
@GitHK review: removed unnecessary nullhandler for library
sanderegg Dec 9, 2020
d8fe51c
added a bit of debug logs
sanderegg Dec 9, 2020
898c9c5
fixed sidecar test by using both versions of node ports
sanderegg Dec 9, 2020
904ca55
bad merge
sanderegg Dec 14, 2020
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
23 changes: 22 additions & 1 deletion .coveragerc
Original file line number Diff line number Diff line change
@@ -1,6 +1,27 @@
[run]
branch = True
omit =
omit =
*/tests/*
*/generated_code/*
parallel = True

[report]
# Regexes for lines to exclude from consideration
exclude_lines =
# Have to re-enable the standard pragma
pragma: no cover

# Don't complain about missing debug-only code:
def __repr__
if self\.debug

# Don't complain if tests don't hit defensive assertion code:
raise AssertionError
raise NotImplementedError

# Don't complain if non-runnable code isn't run:
if 0:
if __name__ == .__main__.:

ignore_errors = True
show_missing = True
4 changes: 4 additions & 0 deletions api/specs/common/schemas/project-v0.0.1-converted.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,8 @@ properties:
type: string
label:
type: string
eTag:
type: string
- type: object
additionalProperties: false
required:
Expand Down Expand Up @@ -221,6 +223,8 @@ properties:
type: string
label:
type: string
eTag:
type: string
- type: object
additionalProperties: false
required:
Expand Down
11 changes: 10 additions & 1 deletion api/specs/common/schemas/project-v0.0.1.json
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,9 @@
},
"label": {
"type": "string"
},
"eTag": {
"type": "string"
}
}
},
Expand Down Expand Up @@ -302,6 +305,9 @@
},
"label": {
"type": "string"
},
"eTag": {
"type": "string"
}
}
},
Expand Down Expand Up @@ -344,7 +350,10 @@
]
},
"parent": {
"type": [ "null", "string" ],
"type": [
"null",
"string"
],
"format": "uuid",
"description": "Parent's (group-nodes') node ID s.",
"examples": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

from .services import PROPERTY_KEY_RE


NodeID = UUID

# Pydantic does not support exporting a jsonschema with Dict keys being something else than a str
Expand Down Expand Up @@ -54,12 +53,18 @@ class BaseFileLink(BaseModel):
)
path: str = Field(
...,
regex=r"^.+$",
description="The path to the file in the storage provider domain",
example=[
"N:package:b05739ef-260c-4038-b47d-0240d04b0599",
"94453a6a-c8d4-52b3-a22d-ccbf81f8d636/d4442ca4-23fd-5b6b-ba6d-0b75f711c109/y_1D.txt",
],
)
e_tag: Optional[str] = Field(
None,
description="Entity tag that uniquely represents the file. The method to generate the tag is not specified (black box).",
alias="eTag",
)

class Config:
extra = Extra.forbid
Expand Down
15 changes: 13 additions & 2 deletions packages/models-library/src/models_library/services.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,18 @@
from enum import Enum
from typing import Dict, List, Optional, Union

from pydantic import BaseModel, EmailStr, Extra, Field, HttpUrl, constr, validator
from pydantic import (
BaseModel,
EmailStr,
Extra,
Field,
HttpUrl,
StrictBool,
StrictFloat,
StrictInt,
constr,
validator,
)
from pydantic.types import PositiveInt

from .basic_regex import VERSION_RE
Expand Down Expand Up @@ -150,7 +161,7 @@ class ServiceProperty(BaseModel):
description="Place the data associated with the named keys in files",
examples=[{"dir/input1.txt": "key_1", "dir33/input2.txt": "key2"}],
)
default_value: Optional[Union[str, float, bool, int]] = Field(
default_value: Optional[Union[StrictBool, StrictInt, StrictFloat, str]] = Field(
None, alias="defaultValue", examples=["Dog", True]
Copy link
Member

Choose a reason for hiding this comment

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

So with the stricts you ensure that "3" or "True" -> str but 3 -> int and True -> bool??

Copy link
Member Author

Choose a reason for hiding this comment

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

so first:
very important is to use the ordering in the Union: go for most restricted values to less restricted (e.g. bool -> int -> float -> str).
Then the strict means that 0 is not False (which could be an issue in some cases but not here yet), also 3 is an int but 3.0 isn't.

)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@
from aioresponses import aioresponses
from aioresponses.core import CallbackResult
from models_library.projects_state import RunningState
from yarl import URL


def creation_cb(url, **kwargs):
def creation_cb(url, **kwargs) -> CallbackResult:

assert "json" in kwargs, f"missing body in call to {url}"
body = kwargs["json"]
Expand All @@ -24,7 +25,7 @@ def creation_cb(url, **kwargs):


@pytest.fixture
async def director_v2_subsystem_mock() -> aioresponses:
async def director_v2_service_mock() -> aioresponses:

"""uses aioresponses to mock all calls of an aiohttpclient
WARNING: any request done through the client will go through aioresponses. It is
Expand Down Expand Up @@ -63,3 +64,38 @@ async def director_v2_subsystem_mock() -> aioresponses:
mock.delete(delete_computation_pattern, status=204, repeat=True)

yield mock


@pytest.fixture
async def storage_v0_service_mock() -> aioresponses:

"""uses aioresponses to mock all calls of an aiohttpclient
WARNING: any request done through the client will go through aioresponses. It is
unfortunate but that means any valid request (like calling the test server) prefix must be set as passthrough.
Other than that it seems to behave nicely
"""
PASSTHROUGH_REQUESTS_PREFIXES = ["http://127.0.0.1", "ws://"]

def get_download_link_cb(url: URL, **kwargs) -> CallbackResult:
file_id = url.path.rsplit("/files/")[1]

return CallbackResult(
status=200, payload={"data": {"link": f"file://{file_id}"}}
)

get_download_link_pattern = re.compile(
r"^http://[a-z\-_]*storage:[0-9]+/v0/locations/[0-9]+/files/.+$"
)

get_locations_link_pattern = re.compile(
r"^http://[a-z\-_]*storage:[0-9]+/v0/locations.*$"
)

with aioresponses(passthrough=PASSTHROUGH_REQUESTS_PREFIXES) as mock:
mock.get(get_download_link_pattern, callback=get_download_link_cb, repeat=True)
mock.get(
get_locations_link_pattern,
status=200,
payload={"data": [{"name": "simcore.s3", "id": "0"}]},
)
yield mock
3 changes: 2 additions & 1 deletion packages/simcore-sdk/requirements/_base.in
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@ aiohttp
aiopg[sa]
networkx
psycopg2-binary
pydantic
pydantic[email]
tenacity
tqdm
trafaret-config

attrs
1 change: 1 addition & 0 deletions packages/simcore-sdk/requirements/_base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ six==1.15.0 # via isodate, jsonschema, openapi-core, openapi-spec-
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/s3wrapper/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, -r requirements/_base.in
tqdm==4.54.1 # via -r requirements/_base.in
trafaret-config==2.0.2 # via -r requirements/_base.in
trafaret==2.1.0 # via -r requirements/../../../packages/service-library/requirements/_base.in, trafaret-config
typing-extensions==3.7.4.3 # via aiohttp, yarl
Expand Down
1 change: 1 addition & 0 deletions packages/simcore-sdk/requirements/_test.in
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ pytest-sugar
pytest-xdist

# mockups/fixtures
alembic
aioresponses
requests
docker
Expand Down
9 changes: 8 additions & 1 deletion packages/simcore-sdk/requirements/_test.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#
aiohttp==3.7.3 # via -c requirements/_base.txt, aioresponses, pytest-aiohttp
aioresponses==0.7.1 # via -r requirements/_test.in
alembic==1.4.3 # via -r requirements/_test.in
apipkg==1.5 # via execnet
astroid==2.4.2 # via pylint
async-timeout==3.0.1 # via -c requirements/_base.txt, aiohttp
Expand All @@ -24,11 +25,14 @@ importlib-metadata==3.1.1 # via -c requirements/_base.txt, pluggy, pytest
iniconfig==1.1.1 # via pytest
isort==5.6.4 # via pylint
lazy-object-proxy==1.4.3 # via -c requirements/_base.txt, astroid
mako==1.1.3 # via alembic
markupsafe==1.1.1 # via mako
mccabe==0.6.1 # via pylint
multidict==5.1.0 # via -c requirements/_base.txt, aiohttp, yarl
packaging==20.7 # via pytest, pytest-sugar
pluggy==0.13.1 # via pytest
pprintpp==0.4.0 # via pytest-icdiff
psycopg2-binary==2.8.6 # via -c requirements/_base.txt, sqlalchemy
py==1.9.0 # via pytest, pytest-forked
pylint==2.6.0 # via -r requirements/_test.in
pyparsing==2.4.7 # via packaging
Expand All @@ -42,9 +46,12 @@ pytest-runner==5.2 # via -r requirements/_test.in
pytest-sugar==0.9.4 # via -r requirements/_test.in
pytest-xdist==2.1.0 # via -r requirements/_test.in
pytest==6.1.2 # via -r requirements/_test.in, pytest-aiohttp, pytest-cov, pytest-forked, pytest-icdiff, pytest-instafail, pytest-mock, pytest-sugar, pytest-xdist
python-dateutil==2.8.1 # via -c requirements/_base.txt, alembic
python-dotenv==0.15.0 # via -r requirements/_test.in
python-editor==1.0.4 # via alembic
requests==2.25.0 # via -r requirements/_test.in, coveralls, docker
six==1.15.0 # via -c requirements/_base.txt, astroid, docker, websocket-client
six==1.15.0 # via -c requirements/_base.txt, astroid, docker, python-dateutil, websocket-client
sqlalchemy[postgresql_psycopg2binary]==1.3.20 # via -c requirements/_base.txt, alembic
termcolor==1.1.0 # via pytest-sugar
toml==0.10.2 # via pylint, pytest
typed-ast==1.4.1 # via astroid
Expand Down
19 changes: 19 additions & 0 deletions packages/simcore-sdk/setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
[bumpversion]
current_version = 0.3.0
commit = True
tag = False

[bumpversion:file:setup.py]
search = version='{current_version}'
replace = version='{new_version}'

[bumpversion:file:src/simcore_sdk/__init__.py]
search = __version__ = '{current_version}'
replace = __version__ = '{new_version}'

[bdist_wheel]
universal = 1

[aliases]
# Define setup.py command aliases here
test = pytest
2 changes: 1 addition & 1 deletion packages/simcore-sdk/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def read_reqs(reqs_path: Path):

setup(
name="simcore-sdk",
version="0.2.0",
version="0.3.0",
packages=find_packages(where="src"),
package_dir={"": "src"},
python_requires=">=3.6",
Expand Down
5 changes: 5 additions & 0 deletions packages/simcore-sdk/src/simcore_sdk/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
""" osparc's simcore-sdk library

"""

__version__ = "0.3.0"
30 changes: 16 additions & 14 deletions packages/simcore-sdk/src/simcore_sdk/config/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,22 @@

import trafaret as T

CONFIG_SCHEMA = T.Dict({
"database": T.String(),
"user": T.String(),
"password": T.String(),
T.Key("minsize", default=1 ,optional=True): T.ToInt(),
T.Key("maxsize", default=4, optional=True): T.ToInt(),
"host": T.Or( T.String, T.Null),
"port": T.Or( T.ToInt, T.Null),
"endpoint": T.Or( T.String, T.Null)
})
CONFIG_SCHEMA = T.Dict(
{
"database": T.String(),
"user": T.String(),
"password": T.String(),
T.Key("minsize", default=1, optional=True): T.ToInt(),
T.Key("maxsize", default=4, optional=True): T.ToInt(),
"host": T.Or(T.String, T.Null),
"port": T.Or(T.ToInt, T.Null),
"endpoint": T.Or(T.String, T.Null),
}
)


# TODO: deprecate!
class Config():

class Config:
def __init__(self):
# TODO: uniform config classes . see server.config file
POSTGRES_URL = env.get("POSTGRES_ENDPOINT", "postgres:5432")
Expand All @@ -31,8 +32,9 @@ def __init__(self):
self._pwd = POSTGRES_PW
self._url = POSTGRES_URL
self._db = POSTGRES_DB
self._endpoint = 'postgresql+psycopg2://{user}:{pw}@{url}/{db}'.format(
user=self._user, pw=self._pwd, url=self._url, db=self._db)
self._endpoint = "postgresql+psycopg2://{user}:{pw}@{url}/{db}".format(
user=self._user, pw=self._pwd, url=self._url, db=self._db
)

@property
def endpoint(self):
Expand Down
7 changes: 3 additions & 4 deletions packages/simcore-sdk/src/simcore_sdk/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
from . import pipeline_models
from .base import metadata

# Add here new models

from .base import metadata

__all__ = (
'metadata'
)
__all__ = "metadata"
4 changes: 1 addition & 3 deletions packages/simcore-sdk/src/simcore_sdk/models/base.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from simcore_postgres_database.models.base import metadata

__all__ = [
"metadata"
]
__all__ = ["metadata"]
2 changes: 1 addition & 1 deletion packages/simcore-sdk/src/simcore_sdk/node_data/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
from . import data_manager
from . import data_manager
4 changes: 4 additions & 0 deletions packages/simcore-sdk/src/simcore_sdk/node_ports/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import logging
import warnings

from . import config as node_config
from . import exceptions
Expand All @@ -10,3 +11,6 @@
log = logging.getLogger(__name__)
log.addHandler(logging.NullHandler())

warnings.warn(
"node_ports is deprecated, use node_ports_v2 instead", category=DeprecationWarning
)
Loading