🐛 — Fix --config option for some commands

This commit is contained in:
Luc Didry 2024-04-29 14:16:23 +02:00
parent 823a62fa57
commit 416728e546
No known key found for this signature in database
GPG key ID: EA868E12D0257E3C
2 changed files with 11 additions and 6 deletions

View file

@ -2,6 +2,8 @@
## [Unreleased]
- 🐛 — Fix --config option for some commands
## 0.1.0
Date: 2024-04-25

View file

@ -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.
"""
# Its 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"""
# Its 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"""
# Its 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__)