Skip to content

Commit

Permalink
Adds builder accessor in application
Browse files Browse the repository at this point in the history
This way you can pull it out and keep building.
  • Loading branch information
elijahbenizzy committed Mar 19, 2024
1 parent 798dd20 commit ba7cb8a
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion burr/core/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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()
Expand All @@ -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,
)

0 comments on commit ba7cb8a

Please sign in to comment.