Skip to content

Commit

Permalink
Merge pull request #37 from Oxen-AI/auth-is-configured
Browse files Browse the repository at this point in the history
Auth is configured
  • Loading branch information
gschoeni committed Feb 2, 2024
2 parents 7007316 + 0195362 commit 729422e
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 14 deletions.
6 changes: 3 additions & 3 deletions oxen/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions oxen/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "oxen"
version = "0.5.3"
version = "0.10.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
Expand All @@ -16,8 +16,8 @@ pyo3-log = "0.9.0"
tokio = { version = "1", features = ["full"] }
pyo3-polars = "0.9.0"
serde_json = "1.0.106"
liboxen = "0.10.9"
# liboxen = { path = "../../rust/Oxen/src/lib" }
liboxen = "0.10.14"
# liboxen = { path = "../../Oxen/src/lib" }

[build-dependencies]
cc = { version = "1.0", features = ["parallel"] }
Expand Down
2 changes: 2 additions & 0 deletions oxen/python/oxen/__init__.py
Expand Up @@ -14,6 +14,7 @@
from oxen import loaders
from oxen.clone import clone
from oxen.init import init
from oxen.config import is_configured

# Names of public modules we want to expose
__all__ = [
Expand All @@ -27,6 +28,7 @@
"Op",
"clone",
"init",
"is_configured",
"RemoteRepo",
"LocalRepo",
"auth",
Expand Down
1 change: 0 additions & 1 deletion oxen/python/oxen/auth.py
Expand Up @@ -4,7 +4,6 @@
import os
import requests


def config_auth(token: str, host: str = "hub.oxen.ai", path: Optional[str] = None):
"""
Configures authentication for a host.
Expand Down
18 changes: 18 additions & 0 deletions oxen/python/oxen/config.py
@@ -0,0 +1,18 @@
from .oxen import auth, util
from oxen.user import config_user
from typing import Optional
import os
import requests

def is_configured():
"""
Checks if the user and auth is configured.
Returns:
`bool`: True if the user and auth is configured, False otherwise.
"""

auth_path = os.path.join(util.get_oxen_config_dir(), "auth_config.toml")
user_path = os.path.join(util.get_oxen_config_dir(), "user_config.toml")

return os.path.exists(auth_path) and os.path.exists(user_path)
10 changes: 6 additions & 4 deletions oxen/python/oxen/remote_repo.py
Expand Up @@ -113,15 +113,17 @@ def __init__(self, path: str, host: Optional[str] = None, revision: str = "main"
def __repr__(self):
return f"RemoteRepo({self._repo.url()})"

def create(self, empty: bool = True):
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: True
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)
self._repo.create(empty, is_public)

def exists(self) -> bool:
"""
Expand Down
8 changes: 5 additions & 3 deletions oxen/src/py_remote_repo.rs
Expand Up @@ -84,14 +84,15 @@ impl PyRemoteRepo {
self.revision = new_revision;
}

fn create(&mut self, empty: bool) -> Result<PyRemoteRepo, PyOxenError> {
fn create(&mut self, empty: bool, is_public: bool) -> Result<PyRemoteRepo, PyOxenError> {
let result = pyo3_asyncio::tokio::get_runtime().block_on(async {
if empty {
let repo = RepoNew::from_namespace_name_host(
let mut repo = RepoNew::from_namespace_name_host(
self.repo.namespace.clone(),
self.repo.name.clone(),
self.host.clone(),
);
repo.is_public = Some(is_public);
api::remote::repositories::create_empty(repo).await
} else {
let config = UserConfig::get()?;
Expand All @@ -101,7 +102,8 @@ impl PyRemoteRepo {
contents: format!("# {}\n", &self.repo.name),
user: user.clone()
}];
let repo = RepoNew::from_files(&self.repo.namespace, &self.repo.name, files);
let mut repo = RepoNew::from_files(&self.repo.namespace, &self.repo.name, files);
repo.is_public = Some(is_public);
api::remote::repositories::create(repo).await
}
})?;
Expand Down

0 comments on commit 729422e

Please sign in to comment.