-
Notifications
You must be signed in to change notification settings - Fork 30
reduce traefik latency check, and remove unnecessary warnings when a pipeline does not exist #2224
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
Changes from 9 commits
bf5d4a6
609a30d
40f5cd1
8136fd7
4781589
fce1ab3
151a0fb
723d286
e51ab6c
c073dd3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ | |
- Shall be used as entry point for all the queries to the database regarding projects | ||
|
||
""" | ||
|
||
import asyncio | ||
import logging | ||
import textwrap | ||
import uuid as uuidlib | ||
|
@@ -22,6 +22,8 @@ | |
from aiopg.sa.connection import SAConnection | ||
from aiopg.sa.result import ResultProxy, RowProxy | ||
from change_case import ChangeCase | ||
from jsonschema.exceptions import ValidationError | ||
from models_library.projects import ProjectAtDB | ||
from servicelib.application_keys import APP_DB_ENGINE_KEY | ||
from simcore_postgres_database.webserver_models import ProjectType, projects | ||
from sqlalchemy import literal_column | ||
|
@@ -37,6 +39,7 @@ | |
ProjectsException, | ||
) | ||
from .projects_fakes import Fake | ||
from .projects_utils import project_uses_available_services | ||
|
||
log = logging.getLogger(__name__) | ||
|
||
|
@@ -307,7 +310,11 @@ async def add_project( | |
prj["tags"] = [] | ||
return prj | ||
|
||
async def load_user_projects(self, user_id: int) -> List[Dict]: | ||
async def load_user_projects( | ||
self, | ||
user_id: int, | ||
filter_by_services: Optional[List[Dict]] = None, | ||
) -> List[Dict]: | ||
log.info("Loading projects for user %s", user_id) | ||
async with self.engine.acquire() as conn: | ||
user_groups: List[RowProxy] = await self.__load_user_groups(conn, user_id) | ||
|
@@ -330,13 +337,17 @@ async def load_user_projects(self, user_id: int) -> List[Dict]: | |
""" | ||
) | ||
projects_list = await self.__load_projects( | ||
conn, query, user_id, user_groups | ||
conn, query, user_id, user_groups, filter_by_services=filter_by_services | ||
) | ||
|
||
return projects_list | ||
|
||
async def load_template_projects( | ||
self, user_id: int, *, only_published=False | ||
self, | ||
user_id: int, | ||
*, | ||
only_published=False, | ||
filter_by_services: Optional[List[Dict]] = None, | ||
) -> List[Dict]: | ||
log.info("Loading public template projects") | ||
|
||
|
@@ -358,7 +369,9 @@ async def load_template_projects( | |
""" | ||
) | ||
|
||
db_projects = await self.__load_projects(conn, query, user_id, user_groups) | ||
db_projects = await self.__load_projects( | ||
conn, query, user_id, user_groups, filter_by_services | ||
) | ||
|
||
projects_list.extend(db_projects) | ||
|
||
|
@@ -378,7 +391,12 @@ async def __load_user_groups( | |
return user_groups | ||
|
||
async def __load_projects( | ||
self, conn: SAConnection, query: str, user_id: int, user_groups: List[RowProxy] | ||
self, | ||
conn: SAConnection, | ||
query: str, | ||
user_id: int, | ||
user_groups: List[RowProxy], | ||
filter_by_services: Optional[List[Dict]] = None, | ||
) -> List[Dict]: | ||
api_projects: List[Dict] = [] # API model-compatible projects | ||
db_projects: List[Dict] = [] # DB model-compatible projects | ||
|
@@ -387,8 +405,21 @@ async def __load_projects( | |
_check_project_permissions(row, user_id, user_groups, "read") | ||
except ProjectInvalidRightsError: | ||
continue | ||
try: | ||
import concurrent.futures | ||
|
||
with concurrent.futures.ThreadPoolExecutor() as pool: | ||
await asyncio.get_event_loop().run_in_executor( | ||
pool, ProjectAtDB.from_orm, row | ||
) | ||
# ProjectAtDB.from_orm(row) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. MNIOR: remove commented Q: does it really make a difference making it async? Did you measure? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm still getting "some" 503 when the system more so I took no chance. |
||
except ValidationError as exc: | ||
log.warning("project failed validation: %s", exc) | ||
sanderegg marked this conversation as resolved.
Show resolved
Hide resolved
|
||
continue | ||
prj = dict(row.items()) | ||
log.debug("found project: %s", pformat(prj)) | ||
if filter_by_services: | ||
if not await project_uses_available_services(prj, filter_by_services): | ||
continue | ||
db_projects.append(prj) | ||
|
||
# NOTE: DO NOT nest _get_tags_by_project in async loop above !!! | ||
|
Uh oh!
There was an error while loading. Please reload this page.