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 authored and chrisburr committed Oct 26, 2023
1 parent 0cddd49 commit 7107065
Show file tree
Hide file tree
Showing 18 changed files with 1,230 additions and 214 deletions.
1 change: 1 addition & 0 deletions run_local.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ 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://${signing_key}"
export DIRACX_SERVICE_AUTH_ALLOWED_REDIRECTS='["http://'$(hostname| tr -s '[:upper:]' '[:lower:]')':8000/docs/oauth2-redirect"]'
export DIRACX_SANDBOX_STORE_BUCKET_NAME=sandboxes
Expand Down
3 changes: 2 additions & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,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/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,7 @@ def generate_cs(
DefaultGroup=user_group,
Users={},
Groups={
user_group: GroupConfig(
JobShare=None, Properties={"NormalUser"}, Quota=None, Users=set()
)
user_group: GroupConfig(Properties={"NormalUser"}, Quota=None, Users=set())
},
)
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: set[SecurityProperty]
Quota: Optional[int]
Users: set[str]
Expand Down Expand Up @@ -103,9 +103,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")
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 7107065

Please sign in to comment.