Skip to content

Commit

Permalink
Remove remote_repo.get_repo
Browse files Browse the repository at this point in the history
- Just construct a RemoteRepo instead
  • Loading branch information
jcelliott committed Jan 15, 2025
1 parent 8756924 commit d3aa100
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 35 deletions.
38 changes: 4 additions & 34 deletions oxen/python/oxen/remote_repo.py
Original file line number Diff line number Diff line change
Expand Up @@ -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="",
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion oxen/src/py_remote_repo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit d3aa100

Please sign in to comment.