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
3d80bb19
Commit
3d80bb19
authored
Jul 22, 2025
by
BO ZHANG
🏀
Browse files
see if table group solves n_file bug
parent
a9e5e5b9
Changes
1
Hide whitespace changes
Inline
Side-by-side
csst_dag/dag/_dispatcher.py
View file @
3d80bb19
...
@@ -466,113 +466,47 @@ class Dispatcher:
...
@@ -466,113 +466,47 @@ class Dispatcher:
if
len
(
plan_basis
)
==
0
or
len
(
data_basis
)
==
0
:
if
len
(
plan_basis
)
==
0
or
len
(
data_basis
)
==
0
:
return
[]
return
[]
obsid_basis
=
data_basis
.
group_by
([
""
])
group_keys
=
[
"dataset"
,
"instrument"
,
"obs_type"
,
"obs_group"
,
"obs_id"
]
obsid_basis
=
data_basis
.
group_by
(
group_keys
)
# unique obsid
u_obsid
=
table
.
unique
(
data_basis
[
"dataset"
,
"obs_id"
])
relevant_plan
=
table
.
join
(
u_obsid
,
plan_basis
,
keys
=
[
"dataset"
,
"obs_id"
],
join_type
=
PLAN_JOIN_TYPE
,
)
print
(
f
"
{
len
(
relevant_plan
)
}
relevant plan records"
)
u_data_obsid
=
table
.
unique
(
data_basis
[
"dataset"
,
"instrument"
,
"obs_type"
,
"obs_group"
,
"obs_id"
,
]
)
# initialize task list
# initialize task list
task_list
=
[]
task_list
=
[]
# loop over obsid
# loop over plan
for
this_obsid_basis
in
obsid_basis
.
groups
:
for
i_data_obsid
in
trange
(
len
(
u_data_obsid
),
**
TQDM_KWARGS
):
this_relevant_plan_basis
=
table
.
join
(
# i_data_obsid = 2
this_obsid_basis
[
group_keys
][:
1
],
this_task
=
dict
(
u_data_obsid
[
i_data_obsid
])
plan_basis
,
this_data_obsid
=
u_data_obsid
[
i_data_obsid
:
i_data_obsid
+
1
]
keys
=
group_keys
,
# join data and plan
this_data_obsid_file
=
table
.
join
(
this_data_obsid
,
data_basis
,
keys
=
[
"dataset"
,
"instrument"
,
"obs_type"
,
"obs_group"
,
"obs_id"
,
],
join_type
=
"inner"
,
)
# print(this_data_obsid_file.colnames)
this_data_obsid_plan
=
table
.
join
(
this_data_obsid
,
relevant_plan
,
keys
=
[
"dataset"
,
"instrument"
,
"obs_type"
,
"obs_group"
,
"obs_id"
,
],
join_type
=
PLAN_JOIN_TYPE
,
join_type
=
PLAN_JOIN_TYPE
,
)
)
assert
len
(
this_relevant_plan_basis
)
==
1
# whether effective detectors all there
n_file_expected
=
this_relevant_plan_basis
[
0
][
"n_file"
]
this_instrument
=
this_data_obsid
[
"instrument"
][
0
]
n_file_found
=
len
(
this_obsid_basis
)
this_n_file
=
(
this_instrument
=
this_relevant_plan_basis
[
0
][
"instrument"
]
this_data_obsid_plan
[
"n_file"
]
if
len
(
this_data_obsid_plan
)
>
0
else
0
detectors_found
=
set
(
this_obsid_basis
[
"detector"
])
detectors_expected
=
set
(
csst
[
this_instrument
].
effective_detector_names
)
this_success
=
(
n_file_expected
==
n_file_found
and
detectors_found
==
detectors_expected
)
)
this_effective_detector_names
=
csst
[
this_instrument
].
effective_detector_names
if
this_instrument
==
"HSTDM"
:
# 不确定以后是1个探测器还是2个探测器
this_n_file_found
=
len
(
this_data_obsid_file
)
this_n_file_expected
=
(
this_n_file
,
this_n_file
*
2
)
this_success
=
this_n_file_found
in
this_n_file_expected
else
:
# for other instruments, e.g., MSC
# n_file_found = len(this_obsgroup_obsid_file)
# n_file_expected = len(effective_detector_names)
# this_success &= n_file_found == n_file_expected
# or more strictly, expected files are a subset of files found
this_success
=
set
(
this_effective_detector_names
)
<=
set
(
this_data_obsid_file
[
"detector"
]
)
n_file_expected
=
int
(
this_data_obsid_plan
[
"n_file"
].
sum
())
n_file_found
=
len
(
this_data_obsid_file
)
# set n_file_expected and n_file_found
this_task
[
"n_file_expected"
]
=
n_file_expected
this_task
[
"n_file_found"
]
=
n_file_found
# append this task
# append this task
task_list
.
append
(
task_list
.
append
(
dict
(
dict
(
task
=
this_task
,
task
=
dict
(
this_relevant_plan_basis
[
group_keys
][
0
])
,
success
=
this_success
,
success
=
this_success
,
relevant_plan
=
this_
data_obsid_plan
,
relevant_plan
=
this_
relevant_plan_basis
,
relevant_data
=
this_
data_
obsid_
file
,
relevant_data
=
this_obsid_
basis
,
n_relevant_plan
=
len
(
this_
data_obsid_plan
),
n_relevant_plan
=
len
(
this_
relevant_plan_basis
),
n_relevant_data
=
len
(
this_
data_
obsid_
file
),
n_relevant_data
=
len
(
this_obsid_
basis
),
relevant_data_id_list
=
(
relevant_data_id_list
=
(
[]
[]
if
len
(
this_
data_
obsid_
file
)
==
0
if
len
(
this_obsid_
basis
)
==
0
else
list
(
this_
data_
obsid_
file
[
"_id"
])
else
list
(
this_obsid_
basis
[
"_id"
])
),
),
n_file_expected
=
this_data_obsid_plan
[
"n_file"
].
sum
()
,
n_file_expected
=
n_file_expected
,
n_file_found
=
len
(
this_data_obsid_file
)
,
n_file_found
=
n_file_found
,
)
)
)
)
return
task_list
return
task_list
@
staticmethod
@
staticmethod
...
...
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