Commit 77d4b6218df6a05cbc9edfb59d0c251fe06b88d5
1 parent
df5f741b
Exists in
dev
Add Filenames to ConfigPyros & add fn_contexts in config_pyros.yml
Showing
6 changed files
with
119 additions
and
3 deletions
Show diff stats
CHANGELOG
1 | 1 | 25-04-2023 (AKo): v0.6.22.0 |
2 | 2 | - Add ephem to pickle seq & add pickle creation when submitting seq via api |
3 | - | |
3 | + - Add Filenames to ConfigPyros & add fn_contexts in config_pyros.yml | |
4 | + | |
4 | 5 | 06-04-2023 (AKo): v0.6.21.1 |
5 | 6 | - Try to fix error when submitting seq simplified (no start_date) |
6 | 7 | ... | ... |
config/pyros/config_pyros.py
1 | 1 | import yaml |
2 | 2 | import os |
3 | +import sys | |
3 | 4 | import time |
4 | 5 | import pykwalify.core |
5 | 6 | from pykwalify.errors import SchemaError |
6 | - | |
7 | - | |
7 | +sys.path.append("../../") | |
8 | +from vendor.guitastro.src.guitastro import FileNames | |
8 | 9 | class ConfigPyros: |
10 | + | |
9 | 11 | def check_and_return_config(self, yaml_file: str, schema_file: str) -> dict: |
10 | 12 | """ |
11 | 13 | Check if yaml_file is valid for the schema_file and return an dictionary of the config file |
... | ... | @@ -81,3 +83,34 @@ class ConfigPyros: |
81 | 83 | self.config_path = os.path.abspath(os.path.join( |
82 | 84 | os.environ.get("DJANGO_PATH"), "../../../config/pyros//")) |
83 | 85 | self.pyros_config = self.read_and_check_config_file(pyros_config_file) |
86 | + fn = FileNames() | |
87 | + contexts = self.pyros_config["general"]["fn_contexts"] | |
88 | + for context, values in contexts.items(): | |
89 | + fn.fcontext_create(context, values["description"]) | |
90 | + fn.fcontext = context | |
91 | + if values.get("naming"): | |
92 | + fn.naming(values["naming"]) | |
93 | + elif values.get("pathnaming"): | |
94 | + fn.pathnaming(values["pathnaming"]) | |
95 | + root_project_path = os.environ.get("PROJECT_ROOT_PATH") | |
96 | + fn.rootdir = os.path.join(root_project_path, values["root_dir"]) | |
97 | + fn.extension = values["extension"] | |
98 | + self.fn = fn | |
99 | +def main(): | |
100 | + os.environ["DJANGO_PATH"] = "../../src/core/pyros_django" | |
101 | + cp = ConfigPyros("config_pyros.yml") | |
102 | + cp.fn.fcontext = "pyros_seq" | |
103 | + print(cp.fn) | |
104 | + file_fullname = "../../data/sequences_pickle/P1/20230319/16.p" | |
105 | + param = cp.fn.naming_get(file_fullname) | |
106 | + print(param) | |
107 | + cp.fn.fname = cp.fn.naming_set(param) | |
108 | + print(cp.fn.fname) | |
109 | + #cp.fn.subdir = cp.fn.subdir_from_filename(file_fullname) | |
110 | + print(type(cp.fn.fname)) | |
111 | + out_fullname = cp.fn.join() | |
112 | + print(os.getcwd()) | |
113 | + print(out_fullname) | |
114 | +if __name__ == "__main__": | |
115 | + | |
116 | + main() | |
84 | 117 | \ No newline at end of file | ... | ... |
config/pyros/config_pyros.yml
... | ... | @@ -3,6 +3,23 @@ general: |
3 | 3 | logo: logo_pyros.png |
4 | 4 | color_theme: sienna |
5 | 5 | nb_element_per_page: 20 |
6 | + fn_contexts: | |
7 | + pyros_img_L0: | |
8 | + root_dir: "data/images/" | |
9 | + description: "pyros_img_L0" | |
10 | + extension: ".fit" | |
11 | + naming: "PyROS.img.1" | |
12 | + pyros_img_L1: | |
13 | + root_dir: "data/images/" | |
14 | + description: "pyros_img_L1" | |
15 | + extension: ".fits" | |
16 | + pathnaming: "PyROS.img.1" | |
17 | + | |
18 | + pyros_seq: | |
19 | + root_dir: "data/sequence/" | |
20 | + description: "pyros_seq" | |
21 | + extension: ".p" | |
22 | + pathnaming: "PyROS.seq.1" | |
6 | 23 | USR: |
7 | 24 | nb_element_per_page: 10 |
8 | 25 | SCP: ~ | ... | ... |
config/pyros/schema_pyros_config.yml
... | ... | @@ -16,6 +16,52 @@ mapping: |
16 | 16 | nb_element_per_page: |
17 | 17 | type: int |
18 | 18 | required: True |
19 | + fn_contexts: | |
20 | + type: map | |
21 | + required: True | |
22 | + mapping: | |
23 | + pyros_img_L0: | |
24 | + type: map | |
25 | + required: True | |
26 | + mapping: | |
27 | + root_dir: | |
28 | + type: str | |
29 | + description: | |
30 | + type: str | |
31 | + extension: | |
32 | + type: str | |
33 | + naming: | |
34 | + type: str | |
35 | + pathnaming: | |
36 | + type: str | |
37 | + pyros_img_L1: | |
38 | + type: map | |
39 | + required: True | |
40 | + mapping: | |
41 | + root_dir: | |
42 | + type: str | |
43 | + description: | |
44 | + type: str | |
45 | + extension: | |
46 | + type: str | |
47 | + naming: | |
48 | + type: str | |
49 | + pathnaming: | |
50 | + type: str | |
51 | + pyros_seq: | |
52 | + type: map | |
53 | + required: True | |
54 | + mapping: | |
55 | + root_dir: | |
56 | + type: str | |
57 | + description: | |
58 | + type: str | |
59 | + extension: | |
60 | + type: str | |
61 | + naming: | |
62 | + type: str | |
63 | + pathnaming: | |
64 | + type: str | |
19 | 65 | USR: |
20 | 66 | type: any |
21 | 67 | SCP: | ... | ... |
privatedev/config/pyros/config_pyros.yml
... | ... | @@ -3,6 +3,23 @@ general: |
3 | 3 | logo: logo_pyros.png |
4 | 4 | color_theme: sienna |
5 | 5 | nb_element_per_page: 20 |
6 | + fn_contexts: | |
7 | + pyros_img_L0: | |
8 | + root_dir: "data/images/" | |
9 | + description: "pyros_img_L0" | |
10 | + extension: ".fit" | |
11 | + naming: "PyROS.img.1" | |
12 | + pyros_img_L1: | |
13 | + root_dir: "data/images/" | |
14 | + description: "pyros_img_L1" | |
15 | + extension: ".fits" | |
16 | + pathnaming: "PyROS.img.1" | |
17 | + | |
18 | + pyros_seq: | |
19 | + root_dir: "data/sequence/" | |
20 | + description: "pyros_seq" | |
21 | + extension: ".p" | |
22 | + pathnaming: "PyROS.seq.1" | |
6 | 23 | USR: |
7 | 24 | nb_element_per_page: 10 |
8 | 25 | SCP: ~ | ... | ... |
src/core/pyros_django/obsconfig/obsconfig_class.py
... | ... | @@ -384,6 +384,8 @@ class OBSConfig: |
384 | 384 | Read the device config file, inherit generic device config if "generic" key is present in "DEVICE". |
385 | 385 | Associate capabilities of attached_devices if this device has attached_devices. |
386 | 386 | Inherit capabilities from generic component and overwritte attributes defined in the device config |
387 | + | |
388 | + This function is recursive (called when there is an attached device and/or when the device is generic) | |
387 | 389 | Args: |
388 | 390 | config_file_name (str): file name to be read |
389 | 391 | is_generic (bool, optional): tells if we're reading a generic configuration (is_generic =True) or not (is_generic = False). Defaults to False. | ... | ... |