-
Notifications
You must be signed in to change notification settings - Fork 77
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
437 implement api to manage indexing queues #444
base: master
Are you sure you want to change the base?
Changes from 5 commits
dfbd212
4f94d57
61e3d34
2fe3782
e455c78
d999998
ae24d88
f381aa6
dd0347d
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 |
---|---|---|
|
@@ -25,6 +25,7 @@ | |
from .models.job import Job, JobStatus | ||
from .models.jobagent import JobAgent | ||
from .models.match import Match | ||
from .models.queuedfile import QueuedFile | ||
from .schema import MatchesSchema, ConfigSchema | ||
from .config import app_config | ||
|
||
|
@@ -56,6 +57,8 @@ class UserRole(Enum): | |
can_list_queries = auto() | ||
can_view_queries = auto() | ||
can_download_files = auto() | ||
can_view_queues = auto() | ||
can_manage_queues = auto() | ||
|
||
|
||
# Type alias for Job ids | ||
|
@@ -474,3 +477,17 @@ def alembic_upgrade(self) -> None: | |
config_file = Path(__file__).parent / "alembic.ini" | ||
alembic_cfg = Config(str(config_file)) | ||
command.upgrade(alembic_cfg, "head") | ||
|
||
def set_queued_file(self, ursadb_id, file_paths): | ||
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.
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. (also ursadb: str, file_paths: list[str] guessing by variable names, but I didn't check the types) 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. or |
||
with self.session() as session: | ||
session.bulk_insert_mappings( | ||
QueuedFile, [ | ||
{ | ||
"ursadb_id": ursadb_id, | ||
"path": file.path, | ||
"index_types": file.index_types, | ||
"tags": file.tags | ||
} for file in file_paths | ||
] | ||
) | ||
session.commit() |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -105,3 +105,9 @@ class ServerSchema(BaseModel): | |
openid_url: Optional[str] | ||
openid_client_id: Optional[str] | ||
about: str | ||
|
||
|
||
class FilePathInputSchema(BaseModel): | ||
path: str | ||
index_types: List[str] | ||
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. We should validate the index_types somehow. I thought there's an enum for that, but apparently not. I think the easiest solution is to add a validator checking that every element is in 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. Can i use List[Literal["gram3", "text4", "hash4", "wide8"]] from typing? |
||
tags: List[str] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
accidental change?