Skip to content

Commit

Permalink
🗑️ Maintenance/ cleanup unsued files (#2855)
Browse files Browse the repository at this point in the history
  • Loading branch information
pcrespov authored Mar 1, 2022
1 parent 99d70df commit 6939ced
Show file tree
Hide file tree
Showing 36 changed files with 681 additions and 3,739 deletions.
27 changes: 10 additions & 17 deletions api/tests/test_repo_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

import json
from pathlib import Path
from typing import Dict, List

import jsonschema
import pytest
Expand All @@ -19,23 +18,17 @@
"-converted.yaml", # equivalent openapi specs file (see scripts/json-schema-to-openapi-schema)
]


# TODO: find json files under services with the word project or similar wildcard??
PROJECTS_PATHS = [
"services/web/server/tests/data/fake-project.json",
"services/web/server/tests/data/workbench_sleeper_payload.json",
"services/web/server/src/simcore_service_webserver/data/fake-template-projects.isan.json",
"services/web/server/src/simcore_service_webserver/data/fake-template-projects.osparc.json",
"services/web/server/src/simcore_service_webserver/data/fake-template-projects.json",
# Add here paths to files containing project's data that can be validated with projects schema
PROJECTS_NAMES = [
"fake-project.json",
"fake-template-projects.hack08.notebooks.json",
"fake-template-projects.isan.2dplot.json",
"fake-template-projects.isan.matward.json",
"fake-template-projects.isan.paraview.json",
"fake-template-projects.isan.ucdavis.json",
"fake-template-projects.sleepers.json",
]

# TODO: check schemas here!?
# ./src/simcore_service_webserver/data/fake-materialDB-LF-getItemList.json
# ./src/simcore_service_webserver/data/fake-modeler-LF-getItemList.json
# ./src/simcore_service_webserver/data/fake-materialDB-LF-getItem.json
# ./src/simcore_service_webserver/data/fake-materialDB-LF-Material2Entities.json
# ./tests/integration/02/workbench_sleeper_dag_adjacency_list.json
# ./tests/integration/02/workbench_sleeper_payload.json
PROJECTS_PATHS = [f"services/web/server/tests/data/{name}" for name in PROJECTS_NAMES]


def _load_data(fpath: Path):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from .utils_assert import assert_status

# WARNING: UserDict is already in https://docs.python.org/3/library/collections.html#collections.UserDict
# TODO: move this to future simcore_service_webserver.users_models.py
AUserDict = Dict[str, Any]

TEST_MARKS = re.compile(r"TEST (\w+):(.*)")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,13 @@
# pylint: disable=no-value-for-parameter

import json
import re
import uuid as uuidlib
from typing import Dict, Optional, Type
from pathlib import Path
from typing import Any, Dict, Optional, Type

from aiohttp import web
from aiohttp.test_utils import TestClient
from models_library.projects_state import ProjectState
from simcore_service_webserver._resources import resources
from simcore_service_webserver.projects.project_models import ProjectDict
from simcore_service_webserver.projects.projects_db import (
APP_PROJECT_DBAPI,
Expand All @@ -21,18 +20,6 @@

from .utils_assert import assert_status

fake_template_resources = [
"data/" + name
for name in resources.listdir("data")
if re.match(r"^fake-template-(.+).json", name)
]

fake_project_resources = [
"data/" + name
for name in resources.listdir("data")
if re.match(r"^fake-user-(.+).json", name)
]


def empty_project_data():
return {
Expand All @@ -47,18 +34,14 @@ def empty_project_data():
}


def load_data(name):
with resources.stream(name) as fp:
return json.load(fp)


async def create_project(
app: web.Application,
params_override: Dict = None,
user_id=None,
params_override: Optional[Dict[str, Any]] = None,
user_id: Optional[int] = None,
*,
force_uuid=False,
) -> Dict:
default_project_json: Optional[Path] = None,
force_uuid: bool = False,
) -> ProjectDict:
"""Injects new project in database for user or as template
:param params_override: predefined project properties (except for non-writeable e.g. uuid), defaults to None
Expand All @@ -70,7 +53,12 @@ async def create_project(
"""
params_override = params_override or {}

project_data = load_data("data/fake-template-projects.isan.json")[0]
project_data = {}
if default_project_json is not None:
# uses default_project_json as base
assert default_project_json.exists(), f"{default_project_json}"
project_data = json.loads(default_project_json.read_text())

project_data.update(params_override)

db = app[APP_PROJECT_DBAPI]
Expand Down Expand Up @@ -109,6 +97,7 @@ def __init__(
clear_all: bool = True,
user_id: Optional[int] = None,
*,
tests_data_dir: Path,
force_uuid: bool = False,
):
assert app # nosec
Expand All @@ -119,6 +108,10 @@ def __init__(
self.prj = {}
self.clear_all = clear_all
self.force_uuid = force_uuid
self.tests_data_dir = tests_data_dir

assert tests_data_dir.exists()
assert tests_data_dir.is_dir()

if not self.clear_all:
# TODO: add delete_project. Deleting a single project implies having to delete as well all dependencies created
Expand All @@ -128,8 +121,13 @@ def __init__(

async def __aenter__(self):
assert self.app # nosec

self.prj = await create_project(
self.app, self.params_override, self.user_id, force_uuid=self.force_uuid
self.app,
self.params_override,
self.user_id,
force_uuid=self.force_uuid,
default_project_json=self.tests_data_dir / "fake-project.json",
)
return self.prj

Expand Down
5 changes: 0 additions & 5 deletions services/api-server/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,6 @@ def read_reqs(reqs_path: Path) -> Set[str]:
"": "src",
},
include_package_data=True,
package_data={
"": [
"mocks/*.y*ml",
]
},
install_requires=PROD_REQUIREMENTS,
test_suite="tests",
tests_require=TEST_REQUIREMENTS,
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

1 change: 0 additions & 1 deletion services/web/server/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ def read_reqs(reqs_path: Path) -> Set[str]:
"": [
"api/v0/openapi.yaml",
"api/v0/schemas/*.json",
"data/*.json",
"templates/**/*.html",
]
},
Expand Down
Loading

0 comments on commit 6939ced

Please sign in to comment.