Skip to content

Commit

Permalink
Upgrade the pyxet version to 0.2.0 (and then release). (#147)
Browse files Browse the repository at this point in the history
Co-authored-by: Hoyt Koepke <hoytak@xethub.com>
  • Loading branch information
Hoyt Koepke and Hoyt Koepke authored Jul 1, 2024
1 parent 1a3360b commit d66fc6c
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 14 deletions.
2 changes: 1 addition & 1 deletion python/pyxet/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "pyxet"
version = "0.1.10-rc1"
version = "0.2.0-rc1"
edition = "2021"

[lib]
Expand Down
7 changes: 4 additions & 3 deletions python/pyxet/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
[build-system]
requires = ["maturin>=0.14.17,<0.15"]
requires = ["maturin>=1.6"]
build-backend = "maturin"

[project]
name = "pyxet"
version = "0.1.10-rc1"
version = "0.2.0-rc1"
description = "pyxet is a Python library that provides a lightweight interface for the XetHub platform."
keywords = [
"ai",
Expand Down Expand Up @@ -43,7 +43,8 @@ dependencies = [
"fsspec==2023.9.2",
"typer>=0.9.0",
"tabulate>=0.9.0",
"s3fs>=2023.6.0"
"s3fs>=2023.6.0",
"boto3"
]
readme = "pypireadme.md"

Expand Down
5 changes: 3 additions & 2 deletions python/pyxet/pyxet/file_system.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,9 @@ def branch_info(self, url):
try:
attr = self._manager.stat(url_path.remote(), url_path.branch, "")
except Exception as e:
print(f"{e}")
sys.exit(1)
print(f"Error accessing repo {url}: {e}")
raise

if attr is None:
raise FileNotFoundError(
f"Branch or repo not found, remote = {url_path.remote()}, branch = {url_path.branch}")
Expand Down
15 changes: 13 additions & 2 deletions python/pyxet/pyxet/sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ class SyncCommand:
def __init__(self, source, destination, use_mtime, message, dryrun, update_size):
self._message = message
self._dryrun = dryrun
self._source = source
self._destination = destination
self._src_fs, self._src_proto, self._src_root = _get_normalized_fs_protocol_and_path(source)
self._dest_fs, self._dest_proto, self._dest_root = _get_normalized_fs_protocol_and_path(destination)
self._use_mtime = use_mtime
Expand All @@ -39,8 +41,11 @@ def validate(self):

# check that the destination specifies an existing branch
# TODO: we may want to be able to sync remote location to a new branch?
self._dest_fs.branch_info(self._dest_root)

try:
self._dest_fs.ls(self._dest_root)
except Exception as e:
raise ValueError(f"Destination {self._destination} does not exist or unable to access ({e}).")

# s3 needs a bucket
if self._src_proto == 's3' and (self._src_root == '/' or self._src_root == ''):
raise ValueError(f"S3 source needs a specified bucket")
Expand All @@ -49,6 +54,12 @@ def validate(self):
if '*' in self._src_root or '*' in self._dest_root:
raise ValueError(f"Wildcards not supported in paths")

# Check that the source is valid
try:
self._src_fs.ls(self._src_root)
except Exception as e:
raise ValueError(f"Source {self._source} does not exist or unable to access ({e}).")

def run(self):
"""
Runs this Sync command, returning SyncStats containing the number of files copied
Expand Down
2 changes: 1 addition & 1 deletion python/pyxet/pyxet/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.1.10-rc1"
__version__ = "0.2.0-rc1"
5 changes: 4 additions & 1 deletion python/pyxet/tests/cli_standalone_cp_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -306,4 +306,7 @@ def test_directory_recursive_upload():
shutil.rmtree(dir)

finally:
delete_branch(b1)
delete_branch(b1)



10 changes: 6 additions & 4 deletions python/pyxet/tests/sync_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,19 +37,21 @@ def check_sync_validate(src, dst, is_valid):
cmd.validate()
assert is_valid
except (ValueError, FileNotFoundError):
assert not is_valid
if is_valid:
raise



def test_sync_command_validate_local():
pyxet.login(CONSTANTS.TESTING_USERNAME, CONSTANTS.TESTING_TOKEN, email="a@a.com")

check_sync_validate('.', f'xet://{CONSTANTS.TESTING_SYNCREPO}/main', True)
check_sync_validate('xet://XetHub/grapp2/main', f'xet://{CONSTANTS.TESTING_SYNCREPO}/sync-branch/sync', False)
check_sync_validate('.', f'xet://{CONSTANTS.TESTING_SYNCREPO}/nonexistent-branch', False)
check_sync_validate('.', f'xet://{CONSTANTS.TESTING_SYNCREPO}/new-branch', False)
check_sync_validate('.', './other', False)
check_sync_validate('.', f'xet://{CONSTANTS.TESTING_SYNCREPO}', False)
check_sync_validate('.', f'xet://non-existant-user/non-existant-repo/', False)
check_sync_validate('.', 'xet://', False)
check_sync_validate('./*', f'xet://{CONSTANTS.TESTING_SYNCREPO}/main', False)
check_sync_validate('./*', f'xet://non-existant-user/', False)
check_sync_validate('./*.py', f'xet://{CONSTANTS.TESTING_SYNCREPO}/main', False)
check_sync_validate('.', f'xet://{CONSTANTS.TESTING_SYNCREPO}/main/foo*', False)

Expand Down

0 comments on commit d66fc6c

Please sign in to comment.