Feat: read and write flux logs
This commit is contained in:
@@ -4,7 +4,9 @@ from pathlib import Path
|
||||
|
||||
import pytest
|
||||
|
||||
from plesna.models.flux import FluxMetaData
|
||||
from plesna.storage.metadata_repository.fs_metadata_repository import FSMetaDataRepository
|
||||
from plesna.storage.metadata_repository.metadata_repository import ExecutionMetaData
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
@@ -51,4 +53,38 @@ def test_register_flux_execution(location, metadata_repository):
|
||||
metadata_filepath = location / metadata_repository.EXECUTION_FILEMODEL.format(flux_id=flux_id)
|
||||
with open(metadata_filepath, "r") as csvfile:
|
||||
content = csvfile.read()
|
||||
assert content == 'datetime,output\n1678887000.0,"{""data"":{""truc"":""machin""}}"\n'
|
||||
assert (
|
||||
content == 'datetime,output\n2023-03-15T14:30:00,"{""data"":{""truc"":""machin""}}"\n'
|
||||
)
|
||||
|
||||
|
||||
def test_register_and_get_flux_execution(location, metadata_repository):
|
||||
flux_id = "my_flux"
|
||||
metadata_repository.add_flux(flux_id)
|
||||
|
||||
metadata_repository.register_flux_execution(
|
||||
flux_id,
|
||||
metadata={
|
||||
"datetime": datetime(2023, 3, 15, 14, 30),
|
||||
"output": {"data": {"truc": "machin"}},
|
||||
},
|
||||
)
|
||||
metadata_repository.register_flux_execution(
|
||||
flux_id,
|
||||
metadata={
|
||||
"datetime": datetime(2024, 3, 15, 14, 30),
|
||||
"output": {"data": {"truc": "chose"}},
|
||||
},
|
||||
)
|
||||
|
||||
logs = metadata_repository.flux_logs(flux_id)
|
||||
assert logs == [
|
||||
ExecutionMetaData(
|
||||
datetime=datetime(2023, 3, 15, 14, 30),
|
||||
output=FluxMetaData(data={"truc": "machin"}),
|
||||
),
|
||||
ExecutionMetaData(
|
||||
datetime=datetime(2024, 3, 15, 14, 30),
|
||||
output=FluxMetaData(data={"truc": "chose"}),
|
||||
),
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user