Skip to content

Commit

Permalink
feat: implement kill, delete and remove job endpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
simon-mazenoux committed Sep 21, 2023
1 parent 07fda54 commit f503216
Show file tree
Hide file tree
Showing 18 changed files with 1,235 additions and 215 deletions.
2 changes: 2 additions & 0 deletions run_local.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ export DIRACX_CONFIG_BACKEND_URL="git+file://${tmp_dir}/cs_store/initialRepo"
export DIRACX_DB_URL_AUTHDB="sqlite+aiosqlite:///:memory:"
export DIRACX_DB_URL_JOBDB="sqlite+aiosqlite:///:memory:"
export DIRACX_DB_URL_JOBLOGGINGDB="sqlite+aiosqlite:///:memory:"
export DIRACX_DB_URL_SANDBOXMETADATADB="sqlite+aiosqlite:///:memory:"
export DIRACX_DB_URL_TASKQUEUEDB="sqlite+aiosqlite:///:memory:"
export DIRACX_SERVICE_AUTH_TOKEN_KEY="file://${tmp_dir}/signing-key/rs256.key"
export DIRACX_SERVICE_AUTH_ALLOWED_REDIRECTS='["http://'$(hostname| tr -s '[:upper:]' '[:lower:]')':8000/docs/oauth2-redirect"]'

Expand Down
3 changes: 2 additions & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ diracx.db.sql =
JobDB = diracx.db.sql:JobDB
JobLoggingDB = diracx.db.sql:JobLoggingDB
SandboxMetadataDB = diracx.db.sql:SandboxMetadataDB
#DummyDB = diracx.db:DummyDB
TaskQueueDB = diracx.db.sql:TaskQueueDB
#DummyDB = diracx.db.sql:DummyDB
diracx.db.os =
JobParametersDB = diracx.db.os:JobParametersDB
diracx.services =
Expand Down
4 changes: 1 addition & 3 deletions src/diracx/cli/internal.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,7 @@ def generate_cs(
DefaultGroup=user_group,
Users={},
Groups={
user_group: GroupConfig(
JobShare=None, Properties=["NormalUser"], Quota=None, Users=[]
)
user_group: GroupConfig(Properties=["NormalUser"], Quota=None, Users=[])
},
)
config = Config(
Expand Down
7 changes: 6 additions & 1 deletion src/diracx/core/config/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class GroupConfig(BaseModel):
AutoAddVOMS: bool = False
AutoUploadPilotProxy: bool = False
AutoUploadProxy: bool = False
JobShare: Optional[int]
JobShare: int = 1000
Properties: list[SecurityProperty]
Quota: Optional[int]
Users: list[str]
Expand Down Expand Up @@ -86,9 +86,14 @@ class JobMonitoringConfig(BaseModel):
useESForJobParametersFlag: bool = False


class JobSchedulingConfig(BaseModel):
EnableSharesCorrection: bool = False


class ServicesConfig(BaseModel):
Catalogs: dict[str, Any] | None
JobMonitoring: JobMonitoringConfig = JobMonitoringConfig()
JobScheduling: JobSchedulingConfig = JobSchedulingConfig()


class OperationsConfig(BaseModel):
Expand Down
6 changes: 6 additions & 0 deletions src/diracx/core/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,9 @@ class BadConfigurationVersion(ConfigurationError):

class InvalidQueryError(DiracError):
"""It was not possible to build a valid database query from the given input"""


class JobNotFound(Exception):
def __init__(self, job_id: int):
self.job_id: int = job_id
super().__init__(f"Job {job_id} not found")
4 changes: 2 additions & 2 deletions src/diracx/core/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ class SortSpec(TypedDict):
class ScalarSearchSpec(TypedDict):
parameter: str
operator: ScalarSearchOperator
value: str
value: str | int


class VectorSearchSpec(TypedDict):
parameter: str
operator: VectorSearchOperator
values: list[str]
values: list[str] | list[int]


SearchSpec = ScalarSearchSpec | VectorSearchSpec
Expand Down
3 changes: 3 additions & 0 deletions src/diracx/db/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ async def init_sql():
db = BaseSQLDB.available_implementations(db_name)[0](db_url)
async with db.engine_context():
async with db.engine.begin() as conn:
# set PRAGMA foreign_keys=ON if sqlite
if db._db_url.startswith("sqlite"):
await conn.exec_driver_sql("PRAGMA foreign_keys=ON")

Check warning on line 40 in src/diracx/db/__main__.py

View check run for this annotation

Codecov / codecov/patch

src/diracx/db/__main__.py#L39-L40

Added lines #L39 - L40 were not covered by tests
await conn.run_sync(db.metadata.create_all)


Expand Down
4 changes: 2 additions & 2 deletions src/diracx/db/sql/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from __future__ import annotations

__all__ = ("AuthDB", "JobDB", "JobLoggingDB", "SandboxMetadataDB")
__all__ = ("AuthDB", "JobDB", "JobLoggingDB", "SandboxMetadataDB", "TaskQueueDB")

from .auth.db import AuthDB
from .jobs.db import JobDB, JobLoggingDB
from .jobs.db import JobDB, JobLoggingDB, TaskQueueDB
from .sandbox_metadata.db import SandboxMetadataDB
Loading

0 comments on commit f503216

Please sign in to comment.