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

feat: add client.me property that calls v1/user (lazily) #51

Merged
merged 2 commits into from
Feb 26, 2024

Conversation

nealrichardson
Copy link
Collaborator

@nealrichardson nealrichardson commented Feb 23, 2024

Replacement for #33, was easier to pull the changes to a fresh branch than try to rebase

Fixes #22.

Copy link

github-actions bot commented Feb 23, 2024

☂️ Python Coverage

current status: ✅

Overall Coverage

Lines Covered Coverage Threshold Status
425 425 100% 80% 🟢

New Files

No new covered files...

Modified Files

File Coverage Status
src/posit/connect/client.py 100% 🟢
src/posit/connect/client_test.py 100% 🟢
TOTAL 100% 🟢

updated for commit: 7b0ddc1 by action🐍

@nealrichardson nealrichardson linked an issue Feb 23, 2024 that may be closed by this pull request
Comment on lines 38 to 40
# Internal attributes to hold settings we fetch lazily
self._server_settings = None
self._current_user: Optional[User] = None
Copy link
Collaborator

Choose a reason for hiding this comment

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

Since we are moving away from caching in Users, should we remove it here for consistency?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good question. I think this is a reasonable one to cache because I don't expect it to change during the session, and like connect_version, I expect that we'll have methods that internally will check something against the current user's (immutable) guid, so we wouldn't want to have to call the server each time. But you could rightly say that's YAGNI.

I don't feel strongly, what do you think? It's a minor change either way.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Saving the GUID seems safe, but other information regarding the current_user could change between calls to client.me.

This morning, at least, I like the idea of not caching anything by convention. We can add it back in if the server request load becomes burdensome.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yep, I agree. I'll remove, then merge.

@nealrichardson nealrichardson merged commit 4e46494 into main Feb 26, 2024
7 checks passed
@nealrichardson nealrichardson deleted the get-me branch February 26, 2024 16:24
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.

SDK client should fetch the current user info at initialization
2 participants