-
Notifications
You must be signed in to change notification settings - Fork 4
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: Content repository resource #300
Conversation
☂️ Python Coverage
Overall Coverage
New Files
Modified Files
|
Nice! I've been encountering this problem as well. Since the Repository is one-to-one with the Content, the interface is different, and the existing Resource/Resources base classes do not work well with this concept. Strictly thinking about the public interface, I agree that using Things get tricky when you introduce the concept of creating a Repository. I think from __future__ import annotations
class Repository(dict):
def delete(self):
pass
class Content(dict):
@property
def repository(self):
# simulated GET endpoint
if hasattr(self, "_repository"):
return self._repository
def create_repository(self, **attributes):
self._repository = Repository(**attributes)
return self._repository
if __name__ == "__main__":
content = Content()
# Nothing here...
print(content.repository)
# Let's create one!
repository = content.create_repository(url="git+https://github.com/posit-dev/posit-sdk-py")
print(repository)
# There it is!
print(content.repository) |
New and improved ergonomics: from posit.connect.client import Client
c = Client("http://localhost:3939", "<redacted>")
valid_content_guid="9086fef1-a600-4eb0-afbd-51791df32efa"
# get content item
content_item = c.content.get(valid_content_guid)
repo = content_item.repository
if repo:
repo.update(branch="this-is-an-updated-branch")
print(repo)
repo.delete()
print(content_item.repository)
else:
print("oops, repo does not exist") |
from earlier conversations with @tdstein , we should only have a single method with a trailiing kwargs so that a single mistype doesn't ruin the typed experience
The situation was really annoying and this is a temp fix
Update resources.py
* main: refactor: removes cache layer from active sequence (#320)
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.
Checking in to see how the Git Repository implementation is going. Looks like you have some exciting things in progress. Feel free to disregard any of my comments if they aren't relevant to where you are headed.
If making Resource immutable or revisiting attributes for fields is worth pursuing, we should split that work out from this pull request to make sure the core Git Repository functionality makes this release.
integration/tests/posit/connect/test_content_item_repository.py
Outdated
Show resolved
Hide resolved
Co-authored-by: Taylor Steinberg <[email protected]>
@schloerke - I went through and removed all getattr calls which triggered the warning in |
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.
Functionality looks good. Just need few minor edits for consistency, then we can merge 👍🏻
integration/tests/posit/connect/test_content_item_repository.py
Outdated
Show resolved
Hide resolved
If an attr is given, `name` is required. If not, `name` is not required
@tdstein looking for feedback here on the semantics / feel of this implementation.
If I have a test script
scratch.py
:here's what the result looks like:
Current things I'm not sure about:
The use of
repository()
as a function to get the repo information. Because we don't have a guid associated with the git info, the patterncontent.repository.get()
can't overload the baseget
function correctly, so I'm not sure the best way to express a singletonget
operation that will never be parameterized.If no repository exists, how do we want to represent that? The API itself returns an API error - I don't know how we want to represent this situation in the SDK.