Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
csst-cicd
csst-dag
Commits
8c272e9d
Commit
8c272e9d
authored
Jul 11, 2025
by
BO ZHANG
🏀
Browse files
refactor: n_frame -> n_file
parent
05fff0a4
Changes
3
Hide whitespace changes
Inline
Side-by-side
csst_dag/_csst/observation.py
View file @
8c272e9d
...
@@ -44,8 +44,8 @@ class CsstPlanObsid(DotDict):
...
@@ -44,8 +44,8 @@ class CsstPlanObsid(DotDict):
def
expected_data_table
(
self
):
def
expected_data_table
(
self
):
contents
=
[]
contents
=
[]
for
detector
in
self
.
detectors
:
for
detector
in
self
.
detectors
:
n_f
ram
e
=
self
.
params
.
num_epec_frame
if
self
.
instrument
==
"HSTDM"
else
1
n_f
il
e
=
self
.
params
.
num_epec_frame
if
self
.
instrument
==
"HSTDM"
else
1
for
_
in
range
(
n_f
ram
e
):
for
_
in
range
(
n_f
il
e
):
contents
.
append
(
contents
.
append
(
dict
(
dict
(
dataset
=
self
.
dataset
,
dataset
=
self
.
dataset
,
...
...
csst_dag/dag/_dispatcher.py
View file @
8c272e9d
...
@@ -59,7 +59,7 @@ PLAN_BASIS_KEYS = (
...
@@ -59,7 +59,7 @@ PLAN_BASIS_KEYS = (
"obs_type"
,
"obs_type"
,
"obs_group"
,
"obs_group"
,
"obs_id"
,
"obs_id"
,
"n_f
ram
e"
,
"n_f
il
e"
,
"_id"
,
"_id"
,
)
)
...
@@ -162,9 +162,14 @@ class Dispatcher:
...
@@ -162,9 +162,14 @@ class Dispatcher:
# plan basis / obsid basis
# plan basis / obsid basis
try
:
try
:
for
_
in
qr
.
data
:
for
_
in
qr
.
data
:
_
[
"n_frame"
]
=
(
if
_
[
"instrument"
]
==
"HSTDM"
:
_
[
"params"
][
"num_epec_frame"
]
if
_
[
"instrument"
]
==
"HSTDM"
else
1
if
_
[
"params"
][
"detector"
]
==
"SIS12"
:
)
this_n_file
=
_
[
"params"
][
"num_epec_frame"
]
*
2
else
:
this_n_file
=
_
[
"params"
][
"num_epec_frame"
]
else
:
this_n_file
=
1
_
[
"n_file"
]
=
this_n_file
except
KeyError
:
except
KeyError
:
print
(
f
"`n_epec_frame` is not found in
{
_
}
"
)
print
(
f
"`n_epec_frame` is not found in
{
_
}
"
)
raise
KeyError
(
f
"`n_epec_frame` is not found in
{
_
}
"
)
raise
KeyError
(
f
"`n_epec_frame` is not found in
{
_
}
"
)
...
@@ -384,7 +389,7 @@ class Dispatcher:
...
@@ -384,7 +389,7 @@ class Dispatcher:
)
)
n_file_expected
=
(
n_file_expected
=
(
this_data_detector_plan
[
"n_f
ram
e"
][
0
]
this_data_detector_plan
[
"n_f
il
e"
][
0
]
if
len
(
this_data_detector_plan
)
>
0
if
len
(
this_data_detector_plan
)
>
0
else
0
else
0
)
)
...
@@ -411,7 +416,7 @@ class Dispatcher:
...
@@ -411,7 +416,7 @@ class Dispatcher:
if
len
(
this_data_detector_files
)
==
0
if
len
(
this_data_detector_files
)
==
0
else
list
(
this_data_detector_files
[
"_id_data"
])
else
list
(
this_data_detector_files
[
"_id_data"
])
),
),
n_file_expected
=
this_data_detector_plan
[
"n_f
ram
e"
].
sum
(),
n_file_expected
=
this_data_detector_plan
[
"n_f
il
e"
].
sum
(),
n_file_found
=
len
(
this_data_detector_files
),
n_file_found
=
len
(
this_data_detector_files
),
)
)
)
)
...
@@ -488,8 +493,8 @@ class Dispatcher:
...
@@ -488,8 +493,8 @@ class Dispatcher:
# whether effective detectors all there
# whether effective detectors all there
this_instrument
=
this_data_obsid
[
"instrument"
][
0
]
this_instrument
=
this_data_obsid
[
"instrument"
][
0
]
this_n_f
ram
e
=
(
this_n_f
il
e
=
(
this_data_obsid_plan
[
"n_f
ram
e"
]
if
len
(
this_data_obsid_plan
)
>
0
else
0
this_data_obsid_plan
[
"n_f
il
e"
]
if
len
(
this_data_obsid_plan
)
>
0
else
0
)
)
this_effective_detector_names
=
csst
[
this_effective_detector_names
=
csst
[
this_instrument
this_instrument
...
@@ -498,7 +503,7 @@ class Dispatcher:
...
@@ -498,7 +503,7 @@ class Dispatcher:
if
this_instrument
==
"HSTDM"
:
if
this_instrument
==
"HSTDM"
:
# 不确定以后是1个探测器还是2个探测器
# 不确定以后是1个探测器还是2个探测器
this_n_file_found
=
len
(
this_data_obsid_file
)
this_n_file_found
=
len
(
this_data_obsid_file
)
this_n_file_expected
=
(
this_n_f
ram
e
,
this_n_f
ram
e
*
2
)
this_n_file_expected
=
(
this_n_f
il
e
,
this_n_f
il
e
*
2
)
this_success
=
this_n_file_found
in
this_n_file_expected
this_success
=
this_n_file_found
in
this_n_file_expected
else
:
else
:
# for other instruments, e.g., MSC
# for other instruments, e.g., MSC
...
@@ -511,7 +516,7 @@ class Dispatcher:
...
@@ -511,7 +516,7 @@ class Dispatcher:
this_data_obsid_file
[
"detector"
]
this_data_obsid_file
[
"detector"
]
)
)
n_file_expected
=
int
(
this_data_obsid_plan
[
"n_f
ram
e"
].
sum
())
n_file_expected
=
int
(
this_data_obsid_plan
[
"n_f
il
e"
].
sum
())
n_file_found
=
len
(
this_data_obsid_file
)
n_file_found
=
len
(
this_data_obsid_file
)
# set n_file_expected and n_file_found
# set n_file_expected and n_file_found
this_task
[
"n_file_expected"
]
=
n_file_expected
this_task
[
"n_file_expected"
]
=
n_file_expected
...
@@ -530,13 +535,29 @@ class Dispatcher:
...
@@ -530,13 +535,29 @@ class Dispatcher:
if
len
(
this_data_obsid_file
)
==
0
if
len
(
this_data_obsid_file
)
==
0
else
list
(
this_data_obsid_file
[
"_id_data"
])
else
list
(
this_data_obsid_file
[
"_id_data"
])
),
),
n_file_expected
=
this_data_obsid_plan
[
"n_f
ram
e"
].
sum
(),
n_file_expected
=
this_data_obsid_plan
[
"n_f
il
e"
].
sum
(),
n_file_found
=
len
(
this_data_obsid_file
),
n_file_found
=
len
(
this_data_obsid_file
),
)
)
)
)
return
task_list
return
task_list
@
staticmethod
def
disptach_obsgroup_detector
(
plan_basis
:
table
.
Table
,
data_basis
:
table
.
Table
,
n_jobs
:
int
=
1
,
):
# unique obsgroup basis
obsgroup_basis
=
table
.
unique
(
plan_basis
[
"dataset"
,
"instrument"
,
"obs_type"
,
"obs_group"
,
]
)
@
staticmethod
@
staticmethod
def
dispatch_obsgroup
(
def
dispatch_obsgroup
(
plan_basis
:
table
.
Table
,
plan_basis
:
table
.
Table
,
...
@@ -583,7 +604,7 @@ class Dispatcher:
...
@@ -583,7 +604,7 @@ class Dispatcher:
# i_obsid = 1
# i_obsid = 1
# print(i_obsid)
# print(i_obsid)
this_instrument
=
this_obsgroup_plan
[
i_obsid
][
"instrument"
]
this_instrument
=
this_obsgroup_plan
[
i_obsid
][
"instrument"
]
this_n_f
ram
e
=
this_obsgroup_plan
[
i_obsid
][
"n_f
ram
e"
]
this_n_f
il
e
=
this_obsgroup_plan
[
i_obsid
][
"n_f
il
e"
]
this_effective_detector_names
=
csst
[
this_effective_detector_names
=
csst
[
this_instrument
this_instrument
].
effective_detector_names
].
effective_detector_names
...
@@ -599,7 +620,7 @@ class Dispatcher:
...
@@ -599,7 +620,7 @@ class Dispatcher:
if
this_instrument
==
"HSTDM"
:
if
this_instrument
==
"HSTDM"
:
# 不确定以后是1个探测器还是2个探测器
# 不确定以后是1个探测器还是2个探测器
this_n_file_found
=
len
(
this_obsgroup_obsid_file
)
this_n_file_found
=
len
(
this_obsgroup_obsid_file
)
this_n_file_expected
=
(
this_n_f
ram
e
,
this_n_f
ram
e
*
2
)
this_n_file_expected
=
(
this_n_f
il
e
,
this_n_f
il
e
*
2
)
this_success
&=
this_n_file_found
in
this_n_file_expected
this_success
&=
this_n_file_found
in
this_n_file_expected
else
:
else
:
# for other instruments, e.g., MSC
# for other instruments, e.g., MSC
...
@@ -612,7 +633,7 @@ class Dispatcher:
...
@@ -612,7 +633,7 @@ class Dispatcher:
this_obsgroup_obsid_file
[
"detector"
]
this_obsgroup_obsid_file
[
"detector"
]
)
)
n_file_expected
=
int
(
this_obsgroup_plan
[
"n_f
ram
e"
].
sum
())
n_file_expected
=
int
(
this_obsgroup_plan
[
"n_f
il
e"
].
sum
())
n_file_found
=
len
(
this_obsgroup_file
)
n_file_found
=
len
(
this_obsgroup_file
)
# set n_file_expected and n_file_found
# set n_file_expected and n_file_found
this_task
[
"n_file_expected"
]
=
n_file_expected
this_task
[
"n_file_expected"
]
=
n_file_expected
...
@@ -631,7 +652,7 @@ class Dispatcher:
...
@@ -631,7 +652,7 @@ class Dispatcher:
if
len
(
this_obsgroup_file
)
==
0
if
len
(
this_obsgroup_file
)
==
0
else
list
(
this_obsgroup_file
[
"_id_data"
])
else
list
(
this_obsgroup_file
[
"_id_data"
])
),
),
n_file_expected
=
this_obsgroup_plan
[
"n_f
ram
e"
].
sum
(),
n_file_expected
=
this_obsgroup_plan
[
"n_f
il
e"
].
sum
(),
n_file_found
=
len
(
this_obsgroup_file
),
n_file_found
=
len
(
this_obsgroup_file
),
)
)
)
)
...
@@ -649,10 +670,9 @@ class Dispatcher:
...
@@ -649,10 +670,9 @@ class Dispatcher:
print
(
f
"
{
len
(
plan_recs
.
data
)
}
plan records"
)
print
(
f
"
{
len
(
plan_recs
.
data
)
}
plan records"
)
print
(
f
"
{
len
(
data_recs
.
data
)
}
data records"
)
print
(
f
"
{
len
(
data_recs
.
data
)
}
data records"
)
for
_
in
plan_recs
.
data
:
for
_
in
plan_recs
.
data
:
_
[
"n_f
ram
e"
]
=
(
_
[
"n_f
il
e"
]
=
(
_
[
"params"
][
"num_epec_frame"
]
if
_
[
"instrument"
]
==
"HSTDM"
else
1
_
[
"params"
][
"num_epec_frame"
]
if
_
[
"instrument"
]
==
"HSTDM"
else
1
)
)
# 未来如果HSTDM的设定简化一些,这里n_frame可以改成n_file,更直观
plan_basis
=
extract_basis_table
(
plan_basis
=
extract_basis_table
(
plan_recs
.
data
,
plan_recs
.
data
,
PLAN_BASIS_KEYS
,
PLAN_BASIS_KEYS
,
...
...
tests/test_dispatcher.py
View file @
8c272e9d
...
@@ -50,6 +50,6 @@ print(task_list_via_obsgroup[0]["relevant_data"].colnames)
...
@@ -50,6 +50,6 @@ print(task_list_via_obsgroup[0]["relevant_data"].colnames)
# relevant plan_basis:
# relevant plan_basis:
# ['dataset', 'instrument', 'obs_type', 'obs_group', 'obs_id', 'detector', 'n_f
ram
e', '_id']
# ['dataset', 'instrument', 'obs_type', 'obs_group', 'obs_id', 'detector', 'n_f
il
e', '_id']
# relevant data_basis:
# relevant data_basis:
# ['dataset', 'instrument', 'obs_type', 'obs_group', 'obs_id', 'detector', 'file_name', '_id']
# ['dataset', 'instrument', 'obs_type', 'obs_group', 'obs_id', 'detector', 'file_name', '_id'
, 'prc_status'
]
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment