-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: change the way we handle store configs
- Loading branch information
1 parent
f37c417
commit fb03383
Showing
10 changed files
with
44 additions
and
38 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
daq_job_type = "handle_alerts" | ||
|
||
[store_config] | ||
daq_job_store_type = "csv" | ||
[store_config.csv] | ||
file_path = "alerts.csv" | ||
add_date = true |
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 |
---|---|---|
@@ -1,7 +1,6 @@ | ||
daq_job_type = "handle_stats" | ||
|
||
[store_config] | ||
daq_job_store_type = "csv" | ||
[store_config.csv] | ||
file_path = "stats.csv" | ||
add_date = false | ||
overwrite = true |
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
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 |
---|---|---|
@@ -1,26 +1,47 @@ | ||
from typing import Any | ||
from typing import Any, Optional | ||
|
||
from msgspec import Struct | ||
|
||
from daq.base import DAQJobInfo | ||
from daq.models import DAQJobConfig, DAQJobMessage | ||
|
||
|
||
class DAQJobStoreConfig(Struct): | ||
class DAQJobStoreConfig(Struct, dict=True): | ||
""" | ||
Used to store the configuration of the DAQ Job Store, usually inside DAQJobConfig. | ||
""" | ||
|
||
daq_job_store_type: str | ||
csv: "Optional[DAQJobStoreConfigCSV]" = None | ||
root: "Optional[DAQJobStoreConfigROOT]" = None | ||
|
||
def has_store_config(self, store_type: Any) -> bool: | ||
for key in dir(self): | ||
if key.startswith("_"): | ||
continue | ||
value = getattr(self, key) | ||
if isinstance(value, store_type): | ||
return True | ||
return False | ||
|
||
|
||
class DAQJobMessageStore(DAQJobMessage): | ||
store_config: dict | DAQJobStoreConfig | ||
store_config: DAQJobStoreConfig | ||
daq_job_info: DAQJobInfo | ||
keys: list[str] | ||
data: list[list[Any]] | ||
prefix: str | None = None | ||
|
||
|
||
class StorableDAQJobConfig(DAQJobConfig): | ||
store_config: dict | ||
store_config: DAQJobStoreConfig | ||
|
||
|
||
class DAQJobStoreConfigCSV(Struct): | ||
file_path: str | ||
add_date: bool | ||
overwrite: Optional[bool] = None | ||
|
||
|
||
class DAQJobStoreConfigROOT(Struct): | ||
file_path: str | ||
add_date: bool |
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