Skip to content

Commit

Permalink
version bump
Browse files Browse the repository at this point in the history
  • Loading branch information
aj-ya committed May 19, 2024
1 parent 7b235cd commit 13c5bdd
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 18 deletions.
2 changes: 1 addition & 1 deletion outpostcli/constants.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
cli_version = "0.0.24"
cli_version = "0.0.25"
CLI_BINARY_NAME = "outpostcli"
26 changes: 11 additions & 15 deletions outpostcli/lfs/commands.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# ref: https://github.com/huggingface/huggingface_hub/blob/main/src/huggingface_hub/commands/lfs.py
from functools import partial
import json
import logging
import os
Expand Down Expand Up @@ -73,12 +74,11 @@ def write_msg(msg: Dict):
def read_msg() -> Optional[Dict]:
"""Read Line delimited JSON from stdin."""
msg = json.loads(sys.stdin.readline().strip())

_log.info(msg)
if "terminate" in (msg.get("type"), msg.get("event")):
# terminate message received
return None


if msg.get("event") not in ("download", "upload"):
# logger.critical("Received unexpected message")
sys.exit(1)
Expand All @@ -91,6 +91,7 @@ def multipart_upload():
"""Command called by git lfs directly and is not meant to be called by the user"""
# ... (rest of the existing code)
init_msg = json.loads(sys.stdin.readline().strip())

if not (init_msg.get("event") == "init" and init_msg.get("operation") == "upload"):
write_msg({"error": {"code": 32, "message": "Wrong lfs init operation"}})
sys.exit(1)
Expand All @@ -101,22 +102,24 @@ def multipart_upload():
# needs to do. It should then respond on stdout with a simple empty
# confirmation structure, as follows:
write_msg({})
_bytes_so_far = 0
bytes_so_far = 0

def on_progress(uploaded_bytes: int):
def on_progress(oid: str, uploaded_bytes: int):
write_msg(
{
"event": "progress",
"oid": oid,
"bytesSoFar": _bytes_so_far + uploaded_bytes,
"bytesSoFar": bytes_so_far + uploaded_bytes,
"bytesSinceLast": uploaded_bytes,
}
)

# After the initiation exchange, git-lfs will send any number of
# transfer requests to the stdin of the transfer process, in a serial sequence.
while True:
_log.info("h")
msg = read_msg()
_log.info("new message: ", msg)
if msg is None:
# When all transfers have been processed, git-lfs will send
# a terminate event to the stdin of the transfer process.
Expand All @@ -126,18 +129,11 @@ def on_progress(uploaded_bytes: int):
oid = msg["oid"]
filepath = msg["path"]

write_msg(
{
"event": "progress",
"oid": oid,
"bytesSoFar": 1,
"bytesSinceLast": 0,
}
)

_log.info(msg)
with open(filepath, "rb") as file_obj:
MultipartTransferAdapter().upload(file_obj, msg["action"], on_progress)
MultipartTransferAdapter().upload(
file_obj, msg["action"], partial(on_progress, oid)
)
write_msg({"event": "complete", "oid": oid})
except HTTPException as e:
_log.error(e, exc_info=True)
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "outpostcli"
version = "0.0.24"
version = "0.0.25"
description = "CLI for Outpost"
readme = "README.md"
license = { file = "LICENSE" }
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

setup(
name="outpostcli",
version="0.0.24",
version="0.0.25",
py_modules=["outpostcli"],
install_requires=["Click", "outpostkit"],
entry_points={
Expand Down

0 comments on commit 13c5bdd

Please sign in to comment.