diff --git a/CHANGELOG.md b/CHANGELOG.md index 255562c..9380d4d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ ## [Unreleased] +- 🐛 — Fix --config option for some commands + ## 0.1.0 Date: 2024-04-25 diff --git a/argos/commands.py b/argos/commands.py index c7da649..1e5cf7b 100644 --- a/argos/commands.py +++ b/argos/commands.py @@ -149,11 +149,12 @@ async def cleandb(max_results, max_lock_seconds, config): - Removes old results from the database. - Removes locks from tasks that have been locked for too long. """ + # It’s mandatory to do it before the imports + os.environ["ARGOS_YAML_FILE"] = config + # The imports are made here otherwise the agent will need server configuration files. from argos.server import queries - os.environ["ARGOS_YAML_FILE"] = config - db = await get_db() removed = await queries.remove_old_results(db, max_results) updated = await queries.release_old_locks(db, max_lock_seconds) @@ -173,13 +174,14 @@ async def cleandb(max_results, max_lock_seconds, config): @coroutine async def reload_config(config): """Read tasks’ configuration and add/delete tasks in database if needed""" + # It’s mandatory to do it before the imports + os.environ["ARGOS_YAML_FILE"] = config + # The imports are made here otherwise the agent will need server configuration files. from argos.server import queries from argos.server.main import get_application, read_config from argos.server.settings import get_app_settings - os.environ["ARGOS_YAML_FILE"] = config - appli = get_application() settings = get_app_settings() config = read_config(appli, settings) @@ -202,11 +204,12 @@ async def reload_config(config): @coroutine async def migrate(config): """Run database migrations""" + # It’s mandatory to do it before the imports + os.environ["ARGOS_YAML_FILE"] = config + # The imports are made here otherwise the agent will need server configuration files. from argos.server.settings import get_app_settings - os.environ["ARGOS_YAML_FILE"] = config - settings = get_app_settings() current_dir = os.path.dirname(__file__)