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-dfs
csst-dfs-client
Commits
cf4ada30
Commit
cf4ada30
authored
Nov 12, 2025
by
Wei Shoulin
Browse files
feat(dfs): add dag_run parameter to write function
parent
b21bc8d9
Pipeline
#11193
failed with stages
in 0 seconds
Changes
2
Pipelines
1
Show whitespace changes
Inline
Side-by-side
csst_dfs_client/other.py
View file @
cf4ada30
...
...
@@ -59,20 +59,21 @@ def get_by_id(_id: str) -> Result:
return
request
.
get
(
f
"/api/other/_id/
{
_id
}
"
)
def
write
(
local_file
:
str
,
instrument
:
Literal
[
"MSC"
,
"IFS"
,
"MCI"
,
"HSTDM"
,
"CPIC"
],
**
kwargs
local_file
:
str
,
instrument
:
Literal
[
"MSC"
,
"IFS"
,
"MCI"
,
"HSTDM"
,
"CPIC"
],
dag_run
:
str
,
**
kwargs
)
->
Result
:
"""
将本地文件写入DFS中
Args:
local_file (str]): 文件路径
instrument (str): 设备,必需为'MSC', 'IFS', 'MCI', 'HSTDM', 'CPIC'之一.
dag_run (str): DAG运行标识.
**kwargs: 额外的关键字参数,这些参数将传递给DFS
Returns:
Result: 操作的结果对象,包含操作是否成功以及相关的错误信息,成功返回数据对象
"""
params
=
{
"instrument"
:
instrument
}
params
=
{
"instrument"
:
instrument
,
"dag_run"
:
dag_run
}
params
.
update
(
kwargs
)
if
not
os
.
path
.
exists
(
local_file
):
raise
FileNotFoundError
(
local_file
)
...
...
tests/test_other.py
View file @
cf4ada30
...
...
@@ -11,7 +11,7 @@ class OtherTestCase(unittest.TestCase):
result
=
other
.
find
(
instrument
=
'MSC'
,
dag_run
=
"test_dag_run"
,
create_time
=
(
"2024-01-01 00:00:00"
,
"202
4
-12-31 23:59:59"
),
create_time
=
(
"2024-01-01 00:00:00"
,
"202
5
-12-31 23:59:59"
),
page
=
1
,
limit
=
10
)
...
...
@@ -24,7 +24,7 @@ class OtherTestCase(unittest.TestCase):
def
test_get_by_id
(
self
):
try
:
test_id
=
"
1212
"
test_id
=
"
6914879b56e864f1f2abce7b
"
result
=
other
.
get_by_id
(
test_id
)
print
(
f
"get_by_id result:
{
result
}
"
)
self
.
assertEqual
(
result
.
code
,
200
,
"error code: "
+
str
(
result
.
code
)
+
", message: "
+
result
.
message
)
...
...
@@ -35,9 +35,11 @@ class OtherTestCase(unittest.TestCase):
def
test_write
(
self
):
try
:
test_file_path
=
"/
path/to/test/file.txt
"
test_file_path
=
"/
Users/wsl/temp/csst/CSST_MSC_MS_SCI_20240617065639_20240617065909_100000020_07_cat.fits
"
result
=
other
.
write
(
local_file
=
test_file_path
,
instrument
=
'MSC'
,
dag_run
=
"test_dag_run"
,
test_param
=
"test_value"
)
print
(
f
"write result:
{
result
}
"
)
...
...
@@ -50,7 +52,7 @@ class OtherTestCase(unittest.TestCase):
try
:
result
=
other
.
delete
(
instrument
=
'MSC'
,
dag_run
=
"test_dag_run
_for_deletion
"
dag_run
=
"test_dag_run"
)
print
(
f
"delete result:
{
result
}
"
)
self
.
assertEqual
(
result
.
code
,
200
,
"error code: "
+
str
(
result
.
code
)
+
", message: "
+
result
.
message
)
...
...
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