From ba7cb8a069c2d084d8fa85d8e0bd4241b3d37698 Mon Sep 17 00:00:00 2001 From: elijahbenizzy Date: Tue, 19 Mar 2024 14:16:18 -0700 Subject: [PATCH] Adds builder accessor in application This way you can pull it out and keep building. --- burr/core/application.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/burr/core/application.py b/burr/core/application.py index 496c876c..d5061755 100644 --- a/burr/core/application.py +++ b/burr/core/application.py @@ -240,6 +240,7 @@ def __init__( uid: str, sequence_id: Optional[int], adapter_set: Optional[LifecycleAdapterSet] = None, + builder: Optional["ApplicationBuilder"] = None, ): self._partition_key = partition_key self._uid = uid @@ -266,6 +267,7 @@ def __init__( } if sequence_id is not None: self._set_sequence_id(sequence_id) + self._builder = builder # @telemetry.capture_function_usage # todo -- capture usage when we break this up into one that isn't called internally # This will be doable when we move sequence ID to the beginning of the function https://github.com/DAGWorks-Inc/burr/pull/73 @@ -1039,6 +1041,15 @@ def partition_key(self) -> Optional[str]: """ return self._partition_key + @property + def builder(self) -> Optional["ApplicationBuilder"]: + """Returns the application builder that was used to build this application. + Note that this asusmes the application was built using the builder. Otherwise, + + :return: The application builder + """ + return self._builder + def _assert_set(value: Optional[Any], field: str, method: str): if value is None: @@ -1369,7 +1380,6 @@ def build(self) -> Application: _validate_app_id(self.app_id) if self.state is None: self.state = State() - if self.initializer: # sets state, sequence_id, and maybe start self._load_from_persister() @@ -1391,4 +1401,5 @@ def build(self) -> Application: partition_key=self.partition_key, sequence_id=self.sequence_id, adapter_set=LifecycleAdapterSet(*self.lifecycle_adapters), + builder=self, )