This repository has been archived by the owner on Aug 5, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Fix circular dependencies for APIs and tests
- Loading branch information
Showing
8 changed files
with
106 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,6 +19,8 @@ | |
# 1100 13th Street NW Suite 800 Washington, D.C. 20005 | ||
# <[email protected]> | ||
|
||
from __future__ import annotations | ||
|
||
import argparse | ||
import logging | ||
import sys | ||
|
@@ -45,8 +47,11 @@ | |
import asyncio | ||
from shapely import wkb, wkt | ||
import typing | ||
import tm_admin | ||
#if typing.TYPE_CHECKING: | ||
from tm_admin.users.api import UsersAPI | ||
# from tm_admin.users.api import UsersAPI | ||
# from tm_admin.tasks.api import TasksAPI | ||
# from tm_admin.projects.api import ProjectsAPI | ||
# The number of threads is based on the CPU cores | ||
info = get_cpu_info() | ||
cores = info["count"] * 2 | ||
|
@@ -69,13 +74,15 @@ def __init__(self): | |
Teamrole.TEAM_MANAGER, | ||
] | ||
from tm_admin.users.api import UsersAPI | ||
self.users = UsersAPI() | ||
self.users = None | ||
self.tasks = None | ||
super().__init__("projects") | ||
|
||
async def initialize(self, | ||
inuri: str, | ||
uapi: UsersAPI, | ||
): | ||
tapi: TasksAPI, | ||
) -> None: | ||
""" | ||
Connect to all tables for API endpoints that require accessing multiple tables. | ||
|
@@ -84,6 +91,8 @@ async def initialize(self, | |
""" | ||
await self.connect(inuri) | ||
await self.getTypes("projects") | ||
self.users = uapi | ||
self.tasks = tapi | ||
|
||
async def getByID(self, | ||
project_id: int, | ||
|
@@ -114,7 +123,7 @@ async def getTeamRole(self, | |
Returns: | ||
(Teamrole): The role of this team in this project | ||
""" | ||
log.warning(f"getProjectByTeam(): unimplemented!") | ||
# log.warning(f"getProjectByTeam(): unimplemented!") | ||
# sql = f"SELECT FROM projects WHERE project_id={project_id}" | ||
# where = [{'teams': {"team_id": team_id, "project_id": project_id}}] | ||
#data = await self.getColumns(['id', 'teams'], where) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,6 +19,8 @@ | |
# 1100 13th Street NW Suite 800 Washington, D.C. 20005 | ||
# <[email protected]> | ||
|
||
from __future__ import annotations | ||
|
||
import argparse | ||
import logging | ||
import sys | ||
|
@@ -33,15 +35,9 @@ | |
from shapely import centroid | ||
from tm_admin.types_tm import Taskcreationmode, Taskstatus, Teamrole, Taskaction | ||
from tm_admin.projects.projects_class import ProjectsTable | ||
from tm_admin.projects.projects_teams_class import Project_teamsTable | ||
from tm_admin.projects.projects_teams_class import Projects_teamsTable | ||
from tm_admin.tasks.tasks_class import TasksTable | ||
# from tm_admin.messages.messages_class import MessagesAPI | ||
from tm_admin.projects.api import ProjectsAPI | ||
from tm_admin.users.users import UsersDB | ||
from tm_admin.teams.teams import TeamsDB | ||
from shapely import wkb, get_coordinates | ||
from tm_admin.dbsupport import DBSupport | ||
from tm_admin.generator import Generator | ||
from tm_admin.tasks.task_history_class import Task_historyTable | ||
import re | ||
# from progress import Bar, PixelBar | ||
|
@@ -50,6 +46,10 @@ | |
from codetiming import Timer | ||
import asyncio | ||
from tm_admin.pgsupport import PGSupport | ||
import typing | ||
#if typing.TYPE_CHECKING: | ||
# from tm_admin.projects.api import ProjectsAPI | ||
# from tm_admin.users.api import UsersAPI | ||
|
||
# The number of threads is based on the CPU cores | ||
info = get_cpu_info() | ||
|
@@ -68,11 +68,14 @@ def __init__(self): | |
(TasksAPI): An instance of this class | ||
""" | ||
super().__init__("tasks") | ||
self.projects = ProjectsAPI() | ||
self.projects = tm_admin.projects.api.ProjectsAPI() | ||
self.users = tm_admin.users.api.UsersAPI() | ||
|
||
async def initialize(self, | ||
inuri: str, | ||
): | ||
papi: ProjectsAPI, | ||
uapi: UsersAPI, | ||
) -> None: | ||
""" | ||
Connect to all tables for API endpoints that require | ||
accessing multiple tables. | ||
|
@@ -82,12 +85,13 @@ async def initialize(self, | |
""" | ||
await self.connect(inuri) | ||
await self.getTypes("tasks") | ||
await self.projects.initialize(inuri) | ||
self.projects = papi | ||
self.users = uapi | ||
|
||
async def getStatus(self, | ||
task_id: int, | ||
project_id: int, | ||
): | ||
) -> Taskstatus: | ||
""" | ||
Get the current status for a task using it's project and task IDs. | ||
|
Oops, something went wrong.