-
Notifications
You must be signed in to change notification settings - Fork 44
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add App.from_name for construction of a lazily-hydratable App #2798
base: main
Are you sure you want to change the base?
Conversation
self._running_app = RunningApp(response.app_id, interactive=False) | ||
|
||
app = _App(name) | ||
app._load = _load |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
super minor but this could maybe just be a constructor argument
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I’m fairly averse to “private parameters” in public interfaces: best case, you confuse users or at least present them with information they don’t need to think about, worse case they try to use it and end up in trouble somehow.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I’d really prefer to just merge __init__
and .from_name
but couldn’t see a simple way to do that.
What would be the behavior with this if a user does the seemingly allowed (from a typing perspective):
? Maybe Thinking some more about this it feels like the whole The core part of an app feels like it's an "atomic group for service deployment [and log collection]"? (with deployment in both the ephemeral and persistent sense) Am I correct that the only reason we even have the lookup/from_name methods on App is for the sandbox usecase, since those currently require apps? |
This is currently (i.e. with
Yes I think that's currently correct. In practice, Sandbox.create just needs an app_id. If we expand the App API to support more programmatic discovery of a deployed App layout (which seems like a good idea) then you could also imagine a lookup operation being useful for that in the future.
That's an interesting idea. Feels like it potentially introduces some complications? E.g. currently with Personally I think the situation with |
Open to revisiting app-less sandboxes if this is a big can of worms! |
Describe your changes
This PR adds a new
App.from_name
method with similar lazy construction semantics to other.from_name
methods on Object subclasses, along with anApp.hydrate
method for on-demand hydration. The intention is to make it possible to deprecateApp.lookup
when we deprecate otherObject.lookup
methods, streamlining object construction onto a single lazy path.As
App
is not a subclass ofObject
we face a decision about whether we should make it one (and leverage the existing hydration plumbing) or add some App-specific plumbing. This PR takes the latter approach, which feels more straightforward now without foreclosing on adapting the other approach later.There's definitely some confusing things here. I've made it so that you can't call
App.hydrate
if you instantiated an App by calling its main constructor (App(name)
). Potentially we will want to leverage lazy-hydration of the App layout when we do App redeployments (i.e. the current_init_local_app_existing
). I think we can punt on that as there are not currently any user-facing workflows where you would want to hydrate the App and then access its layout, but we've tlaked about it, e.g. for Function discovery after looking up a deployed App.Part of CLI-96
Backward/forward compatibility checks
Check these boxes or delete any item (or this section) if not relevant for this PR.
Note on protobuf: protobuf message changes in one place may have impact to
multiple entities (client, server, worker, database). See points above.
Changelog
App.from_name
methods for lazily constructing an App based on a lookup and anApp.hydrate
method for hydrating it with server metadata on demand. These methods should be used instead of the eagerApp.lookup
method, which will be deprecated soon (along with other.lookup
methods). Note thatApp.from_name
is primarily useful when you need an App to associate with amodal.Sandbox
; other use-cases should continue to create Apps via the main constructor (app = App(name)
).