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: ...@@ -59,20 +59,21 @@ def get_by_id(_id: str) -> Result:
return request.get(f"/api/other/_id/{_id}") return request.get(f"/api/other/_id/{_id}")
def write( 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: ) -> Result:
""" """
将本地文件写入DFS中 将本地文件写入DFS中
Args: Args:
local_file (str]): 文件路径 local_file (str]): 文件路径
instrument (str): 设备,必需为'MSC', 'IFS', 'MCI', 'HSTDM', 'CPIC'之一.
dag_run (str): DAG运行标识.
**kwargs: 额外的关键字参数,这些参数将传递给DFS **kwargs: 额外的关键字参数,这些参数将传递给DFS
Returns: Returns:
Result: 操作的结果对象,包含操作是否成功以及相关的错误信息,成功返回数据对象 Result: 操作的结果对象,包含操作是否成功以及相关的错误信息,成功返回数据对象
""" """
params = {"instrument": instrument} params = {"instrument": instrument, "dag_run": dag_run}
params.update(kwargs) params.update(kwargs)
if not os.path.exists(local_file): if not os.path.exists(local_file):
raise FileNotFoundError(local_file) raise FileNotFoundError(local_file)
......
...@@ -11,7 +11,7 @@ class OtherTestCase(unittest.TestCase): ...@@ -11,7 +11,7 @@ class OtherTestCase(unittest.TestCase):
result = other.find( result = other.find(
instrument='MSC', instrument='MSC',
dag_run="test_dag_run", 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, page=1,
limit=10 limit=10
) )
...@@ -24,7 +24,7 @@ class OtherTestCase(unittest.TestCase): ...@@ -24,7 +24,7 @@ class OtherTestCase(unittest.TestCase):
def test_get_by_id(self): def test_get_by_id(self):
try: try:
test_id = "1212" test_id = "6914879b56e864f1f2abce7b"
result = other.get_by_id(test_id) result = other.get_by_id(test_id)
print(f"get_by_id result: {result}") print(f"get_by_id result: {result}")
self.assertEqual(result.code, 200, "error code: " + str(result.code) + ", message: " + result.message) self.assertEqual(result.code, 200, "error code: " + str(result.code) + ", message: " + result.message)
...@@ -35,9 +35,11 @@ class OtherTestCase(unittest.TestCase): ...@@ -35,9 +35,11 @@ class OtherTestCase(unittest.TestCase):
def test_write(self): def test_write(self):
try: 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( result = other.write(
local_file=test_file_path, local_file=test_file_path,
instrument='MSC',
dag_run="test_dag_run",
test_param="test_value" test_param="test_value"
) )
print(f"write result: {result}") print(f"write result: {result}")
...@@ -50,7 +52,7 @@ class OtherTestCase(unittest.TestCase): ...@@ -50,7 +52,7 @@ class OtherTestCase(unittest.TestCase):
try: try:
result = other.delete( result = other.delete(
instrument='MSC', instrument='MSC',
dag_run="test_dag_run_for_deletion" dag_run="test_dag_run"
) )
print(f"delete result: {result}") print(f"delete result: {result}")
self.assertEqual(result.code, 200, "error code: " + str(result.code) + ", message: " + result.message) 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