Skip to content

Commit

Permalink
Engines are persistent by default
Browse files Browse the repository at this point in the history
  • Loading branch information
sapetnioc committed Apr 26, 2024
1 parent 82675f5 commit 2cf1cdc
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion capsul/config/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ class EngineConfiguration(Controller):
python_modules: list[str]

database: str = "builtin"
persistent: bool
persistent: bool = True

start_workers: field(
type_=dict, default_factory=lambda: default_engine_start_workers
Expand Down
10 changes: 6 additions & 4 deletions capsul/database/populse_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ def get_or_create_engine(self, engine, update_database=False):
if persistent is undefined:
persistent = db.tmp.get() is None
if row:
engine_id = row[0]
engine_id = row[0][0]
if update_database:
# Update configuration stored in database
db.capsul_engine[engine_id].update(
Expand Down Expand Up @@ -219,7 +219,6 @@ def dispose_engine(self, engine_id):
if row:
connections, persistent, executions = row
connections -= 1
db.capsul_engine[engine_id].label = None
if connections == 0 and not persistent:
# Check if some executions had not been disposed
erase = True
Expand Down Expand Up @@ -260,7 +259,6 @@ def executions_summary(self, engine_id):
"done",
"failed",
],
as_list=True,
)
if info:
for i in ("waiting", "ready", "ongoing", "done", "failed"):
Expand Down Expand Up @@ -329,7 +327,11 @@ def pop_job_json(self, engine_id, start_time):
if not os.path.exists(self.path):
return None, None
with self.storage.data(write=True) as db:
executions = db.capsul_engine[engine_id].executions.get()
if db is None:
# database doesn't exist anymore
executions = None
else:
executions = db.capsul_engine[engine_id].executions.get()
if executions is None:
# engine_id does not exist anymore
# return None to say to workers that they can die
Expand Down

0 comments on commit 2cf1cdc

Please sign in to comment.