Commit cf4ada30 authored by Wei Shoulin's avatar Wei Shoulin
Browse files

feat(dfs): add dag_run parameter to write function

parent b21bc8d9
Pipeline #11193 failed with stages
in 0 seconds
......@@ -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)
......
......@@ -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", "2024-12-31 23:59:59"),
create_time=("2024-01-01 00:00:00", "2025-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)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment