From d3aa1008e6b1d42456ef82cb74471e93b53fc289 Mon Sep 17 00:00:00 2001 From: Joshua Elliott Date: Wed, 15 Jan 2025 09:57:02 -0700 Subject: [PATCH] Remove remote_repo.get_repo - Just construct a RemoteRepo instead --- oxen/python/oxen/remote_repo.py | 38 ++++----------------------------- oxen/src/py_remote_repo.rs | 2 +- 2 files changed, 5 insertions(+), 35 deletions(-) diff --git a/oxen/python/oxen/remote_repo.py b/oxen/python/oxen/remote_repo.py index 0a68002..425c68a 100644 --- a/oxen/python/oxen/remote_repo.py +++ b/oxen/python/oxen/remote_repo.py @@ -5,27 +5,6 @@ from .oxen import PyRemoteRepo, remote -def get_repo(name: str, host: str = "hub.oxen.ai", scheme: str = "https"): - """ - Get a RemoteRepo object for the specified name. For example 'ox/CatDogBBox'. - - Args: - name: `str` - Name of the repository in the format 'namespace/repo_name'. - host: `str` - The host to connect to. Defaults to 'hub.oxen.ai' - Returns: - [RemoteRepo](/python-api/remote_repo) - """ - py_repo = remote.get_repo(name, host, scheme) - - if py_repo is None: - raise ValueError(f"Repository {name} not found") - - repo_id = f"{py_repo.namespace()}/{py_repo.name()}" - return RemoteRepo(repo_id, py_repo.host, py_repo.revision, py_repo.scheme) - - def create_repo( name: str, description="", @@ -56,7 +35,8 @@ def create_repo( Returns: [RemoteRepo](/python-api/remote_repo) """ - return remote.create_repo(name, description, is_public, host, scheme, files) + py_repo = remote.create_repo(name, description, is_public, host, scheme, files) + return RemoteRepo(name, py_repo.host, py_repo.revision, py_repo.scheme) class RemoteRepo: @@ -122,22 +102,12 @@ def __init__( The scheme to use for the remote url. Default: 'https' """ self._repo = PyRemoteRepo(repo_id, host, revision, scheme) + if not self._repo.exists(): + raise ValueError(f"Repository {repo_id} not found") def __repr__(self): return f"RemoteRepo({self._repo.url()})" - def create(self, empty: bool = False, is_public: bool = False): - """ - Will create the repo on the remote server. - - Args: - empty: `bool` - Whether to create an empty repo or not. Default: False - is_public: `bool` - Whether the repository is public or private. Default: False - """ - self._repo.create(empty, is_public) - def exists(self) -> bool: """ Checks if this remote repo exists on the server. diff --git a/oxen/src/py_remote_repo.rs b/oxen/src/py_remote_repo.rs index c466ad2..1684030 100644 --- a/oxen/src/py_remote_repo.rs +++ b/oxen/src/py_remote_repo.rs @@ -62,7 +62,7 @@ impl PyRemoteRepo { fn __repr__(&self) -> String { format!( - "RemoteRepo(namespace='{}', name='{}', url='{}')", + "PyRemoteRepo(namespace='{}', name='{}', url='{}')", self.namespace(), self.name(), self.url()