diff --git a/python_modules/dagster/dagster/_core/definitions/schedule_definition.py b/python_modules/dagster/dagster/_core/definitions/schedule_definition.py index dc2eb3ab21c59..4630e0d59c67a 100644 --- a/python_modules/dagster/dagster/_core/definitions/schedule_definition.py +++ b/python_modules/dagster/dagster/_core/definitions/schedule_definition.py @@ -234,8 +234,8 @@ def resources(self) -> Resources: """Mapping of resource key to resource definition to be made available during schedule execution. """ - if self._resources_container.has_resources: - return self._resources_container.get_resources() + if self._resources_container.has_been_accessed: + return self._resources_container.get_already_accessed_resources() instance = self.instance if self._instance or self._instance_ref else None return self._resources_container.make_resources("build_schedule_context", instance=instance) diff --git a/python_modules/dagster/dagster/_core/execution/context/dual_state_context.py b/python_modules/dagster/dagster/_core/execution/context/dual_state_context.py index 53a3cca9a579a..e3242c256b0b5 100644 --- a/python_modules/dagster/dagster/_core/execution/context/dual_state_context.py +++ b/python_modules/dagster/dagster/_core/execution/context/dual_state_context.py @@ -58,14 +58,12 @@ def call_on_exit(self) -> None: def call_on_del(self) -> None: self._exit_stack.close() + @property def has_been_accessed(self) -> bool: - return self._resources is not None - - def has_resources(self) -> bool: return bool(self._resources) - def get_resources(self) -> Resources: - assert self.has_resources + def get_already_accessed_resources(self) -> Resources: + check.invariant(self.has_been_accessed) return check.not_none(self._resources) def make_resources(