Skip to content
Snippets Groups Projects
Commit 4aca830a authored by dilawar's avatar dilawar :ant:
Browse files

chore: minor cleanup in the cli options.

parent 7e295492
No related branches found
No related tags found
No related merge requests found
Pipeline #3585 failed with stages
in 1 minute and 2 seconds
......@@ -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
......
......@@ -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__":
......
No preview for this file type
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment