Skip to content
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

tickets/DM-46480: adopt shared rubin-nublado-client #374

Merged
merged 6 commits into from
Oct 29, 2024
Merged

Conversation

athornton
Copy link
Member

Rather than use internal client, use the shared client from the nublado repo.

This is currently dependent on DM-46480 branch of nublado, and will be changed once that work is merged and released.

Copy link
Member

@fajpunk fajpunk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My main architectural questions are:

  • Would it be cleaner to keep a nublado support in mobu, whose only job is to wrap the extracted nublado client's methods and do the exception transormations, instead of doing those at each call site? Would that even be possible?
  • Is there any way to extract out the common stuff we're doing in all of the wrapped exceptions, like adding annotations and mobu fields, somehow so we don't have to repeat the same logic in every wrapped exception?

src/mobu/exceptions.py Outdated Show resolved Hide resolved
src/mobu/exceptions.py Outdated Show resolved Hide resolved
src/mobu/exceptions.py Outdated Show resolved Hide resolved
src/mobu/exceptions.py Show resolved Hide resolved
src/mobu/exceptions.py Show resolved Hide resolved
self.mobu_init(monkey=monkey, event=event)

@classmethod
def from_client_exception(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this isn't used in any calling code, can it just be smooshed into from_exception?

Copy link
Member Author

@athornton athornton Oct 28, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IDK. In most cases, from_exception() is how the base class turns its parent exception into the NubladoClientException. We'd be changing the call signature if we made it an override.

My tendency is to pick a different name, but maybe I'm wrong about that? I feel like it's a kind of useful distinction between "this is already a NubladoClientSlackException" (or SlackWeb) and therefore mostly-tame already, versus "naw, dawg, this is turning anything into one of our own exceptions".

src/mobu/exceptions.py Show resolved Hide resolved
src/mobu/services/business/nublado.py Show resolved Hide resolved
src/mobu/services/business/nublado.py Show resolved Hide resolved
Comment on lines +139 to +140
"description": ANY,
"reference": ANY,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we lose the ability to test specific descriptions and references here?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(and elsewhere in these tests)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because it wasn't clear to me that we would want to set them directly or use the ones from the NubladoClient testing suite, and there they are not exposed well. I think.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The thing here is, they're a magic constant (like "w_2077_43") that doesn't appear in any of the mobu code, because it's just being pulled in from the client testing code, and if the client testing code wants to change them (although, why would it?) then why should mobu break.

Maybe I should be exposing it in the client testing layer? But that feels weird too because it's basically just a test fixture.

@athornton
Copy link
Member Author

The right way to address the architectural concerns (and this is something I talked about a little with @rra ) is ultimately to turn almost all of these exception fields into annotations. That will weaken the typing a little, but will make composing exceptions a whole lot easier.

It's a little subtle, in that we want to maintain the one-column vs two-column distinctions (that is, blocks versus fields) and large amounts of data will need to be packaged as attachments, and that (or something near there) is not documented in the Slack API...and then all of that really needs to be in Safir, neither in Mobu nor in NubladoClient.

But that's going to be a lot of work, so what I want to do in the immediate term is to land splitting out the NubladoClient into the Nublado monorepo, and adopting it into ghostwriter, mobu, and noteburst.

In addition to being a lot of work, the annotation-based Safir rewrite is work we should not undertake without Jonathan, who will have strong opinions about how Safir ought to work, so we really can't tackle it until 2025 when he's back.

@sqreadmin
Copy link

My main architectural questions are:

* Would it be cleaner to keep a nublado support in mobu, whose only job is to wrap the extracted nublado client's methods and do the exception transormations, instead of doing those at each call site?  Would that even be possible?

* Is there any way to extract out the common stuff we're doing in all of the wrapped exceptions, like adding annotations and mobu fields, somehow so we don't have to repeat the same logic in every wrapped exception?

Uh. Trying to think through this. Because the stuff we're adding isn't part of the client...buuuut if it ALSO took a CodeContext on each call, or updated a CodeContext object that DID live on the client....anyway, let's see.

@sqreadmin
Copy link

sqreadmin commented Oct 28, 2024

I guess it's the moral equivalent of _convert_exception() in the Nublado Client. Hm.

I still don't see how we would get away from updating each exception individually, though, because monkey and event depend on something that definitely isn't a client property.

There probably is some much more clever way to do it, but I think I'm going to put that off until we do the proper refactoring of the Safir base Slack exception class.

@sqreadmin
Copy link

Waaaaait why am I logged in as sqreadmin?

@athornton athornton requested a review from fajpunk October 28, 2024 21:05
Copy link
Member

@fajpunk fajpunk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One more typo, but yeah, I guess we can put off a refactor until we do the bigger refactor

src/mobu/exceptions.py Outdated Show resolved Hide resolved
@athornton athornton merged commit be04caa into main Oct 29, 2024
4 checks passed
@athornton athornton deleted the tickets/DM-46480 branch October 29, 2024 04:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants