Skip to content

Commit

Permalink
Load patches in static definition
Browse files Browse the repository at this point in the history
  • Loading branch information
Olivier Michaud committed Oct 17, 2024
1 parent c496e9c commit d66d70d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
2 changes: 2 additions & 0 deletions src/saturn_engine/worker_manager/api/jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ def update_job(job_name: str) -> Json[UpdateResponse]:
def post_sync() -> Json[JobsSyncResponse]:
"""Create jobs that are due to be scheduled."""
with session_scope() as session:
# We reset static definition at each jobs sync
current_app.saturn.load_static_definition(session=session)
sync_jobs(
static_definitions=current_app.saturn.static_definitions,
session=session,
Expand Down
11 changes: 7 additions & 4 deletions src/saturn_engine/worker_manager/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,24 @@ def static_definitions(self) -> StaticDefinitions:
return self._static_definitions

def load_static_definition(self, session: AnySession) -> None:
self._static_definitions = _load_static_definition(
session=session, config=self.config
)
static_definition = _load_static_definition(session=session, config=self.config)
if static_definition:
self._static_definitions = static_definition


def _load_static_definition(
config: WorkerManagerConfig, session: AnySession
) -> StaticDefinitions:
) -> StaticDefinitions | None:
"""
Static definitions contain objects defined in a declarative configuration:
- Inventories
- Topics
- Jobs
- JobDefinitions
"""
if not config.static_definitions_jobs_selector:
return None

definitions = load_definitions_from_paths(config.static_definitions_directories)
if config.static_definitions_jobs_selector:
definitions = filter_with_jobs_selector(
Expand Down

0 comments on commit d66d70d

Please sign in to comment.