diff --git a/README.md b/README.md index 66ad82c9d09e6750c398f59851cb241e108592ca..1522aeb17811a19457b08037150850f7f9d20b14 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,8 @@ This is the cli utility of the BiTIA project. The other component is Install it using pip. ``` -pip install bitia +python3 -m pip install bitia +bitia --version ``` ## BiTIA runner diff --git a/bitia/__main__.py b/bitia/__main__.py index 2555dc0cb9c2307d137b8fd68ecad22065c53d34..fb44e679ec24b48523b1ebe3e56a5d40a8dcab4b 100644 --- a/bitia/__main__.py +++ b/bitia/__main__.py @@ -6,17 +6,18 @@ bitia dir __author__ = "Dilawar Singh" __email__ = "dilawar@subcom.tech" +import sys import typing as T import requests import zipfile -import logging -from rich.logging import RichHandler - from pathlib import Path import tempfile - +import bitia from bitia.checksumdir import dirhash +import logging +from rich.logging import RichHandler + FORMAT = "%(message)s" logging.basicConfig( level="NOTSET", format=FORMAT, datefmt="[%X]", handlers=[RichHandler()] @@ -29,6 +30,11 @@ import typer app = typer.Typer() +def version_callback(value: bool): + if value: + print(bitia.version()) + + def bitia_dir() -> Path: """CLI cache directory""" bdir = Path(tempfile.gettempdir()) / "bitia" @@ -64,7 +70,7 @@ def prepare_archive(user_dir: Path) -> Path: assert dinfo["files"], f"No file found in {user_dir}" with zipfile.ZipFile(outfile, "w", zipfile.ZIP_DEFLATED) as zfile: for entry in dinfo["files"]: - logging.info(f"Adding {entry} to zipfile") + logger.info(f"Adding {entry} to zipfile") zfile.write(entry) # check the prepared zip file. @@ -93,8 +99,8 @@ def submit_job(pipeline_zip: Path, server: str): @app.command() -def submit(user_input, server: str = "https://public.bitia.link"): - """Submit your job. +def submit(user_input: str, server: str = "https://public.bitia.link"): + """Submit your pipelin (url, directory, zip_file). Prepare the user directory to send to the server. User can also provide link to the pipeline to run. @@ -108,8 +114,14 @@ def submit(user_input, server: str = "https://public.bitia.link"): raise RuntimeError(f"Not supported: {path}") submit_job(pipeline_zip, server) else: - logger.warning(f"Fetching pipeline from url is not supported") - quit(-1) + logger.warning("Fetching pipeline from url is not supported") + sys.exit(-1) + + +@app.command() +def version() -> str: + """version information""" + print(bitia.version()) if __name__ == "__main__": diff --git a/bitia/__pycache__/__main__.cpython-39.pyc b/bitia/__pycache__/__main__.cpython-39.pyc index 2eab3379b3ece7e3f56ff1c3656cff0a17376178..706fd50257066187dbf23dfc389e348770128f2a 100644 Binary files a/bitia/__pycache__/__main__.cpython-39.pyc and b/bitia/__pycache__/__main__.cpython-39.pyc differ