diff --git a/plesna/storage/metadata_repository/fs_metadata_repository.py b/plesna/storage/metadata_repository/fs_metadata_repository.py index ba07431..a7f5b3e 100644 --- a/plesna/storage/metadata_repository/fs_metadata_repository.py +++ b/plesna/storage/metadata_repository/fs_metadata_repository.py @@ -3,6 +3,7 @@ from datetime import datetime import csv import json +from plesna.libs.string_tools import StringToolsError, extract_values_from_pattern from plesna.storage.metadata_repository.metadata_repository import ( ExecutionLog, MetaDataRepository, @@ -34,7 +35,15 @@ class FSMetaDataRepository(MetaDataRepository): def fluxes(self) -> list[str]: """List fluxes's ids""" - raise NotImplementedError + fluxes = [] + for filepath in self._basepath.iterdir(): + try: + founded = extract_values_from_pattern(self.FILEMODEL["execution"], filepath.name) + except StringToolsError: + pass + else: + fluxes.append(founded["flux_id"]) + return fluxes def add_flux(self, flux_id: str) -> str: """Get the flux metadata""" diff --git a/tests/storage/test_fs_metadata_repository.py b/tests/storage/test_fs_metadata_repository.py index c587525..f96f7f3 100644 --- a/tests/storage/test_fs_metadata_repository.py +++ b/tests/storage/test_fs_metadata_repository.py @@ -114,3 +114,10 @@ def test_register_and_get_last_log(metadata_repository): datetime=datetime(2024, 3, 15, 14, 30), output=FluxMetaData(data={"truc": "chose"}), ) + + +def test_register_and_list_fluxes(metadata_repository): + flux_ids = ["my_flux", "flux2", "blahblah"] + for f in flux_ids: + metadata_repository.add_flux(f) + assert metadata_repository.fluxes() == flux_ids