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

temp:

parent 6675447d
No related branches found
No related tags found
1 merge request!2version 0.2.0
Pipeline #3701 failed with stages
in 2 minutes and 3 seconds
......@@ -79,24 +79,24 @@ def session(func):
@app.command("submit")
@session
def submit_pipeline(user_input: str, server: str = DEFAULT_SERVER):
def submit_pipeline(user_input: str, rerun: bool = False, server: str = DEFAULT_SERVER):
"""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.
"""
pipeline_zip = user_input_to_pipeline(user_input)
containers = submit_job(pipeline_zip, server=server)
containers = submit_job(pipeline_zip, rerun=rerun, server=server)
logger.info(f" Got containers {containers}")
return containers
@app.command("run")
@session
def run_pipeline(user_input: str, server: str = DEFAULT_SERVER):
def run_pipeline(user_input: str, rerun: bool = False, server: str = DEFAULT_SERVER):
"""Run a pipeline"""
pipeline_zip = user_input_to_pipeline(user_input)
res = submit_job(pipeline_zip, server=server)
res = submit_job(pipeline_zip, rerun=rerun, server=server)
return _log_container(res["container"], server=server)
......@@ -107,6 +107,9 @@ def version():
def _log_container(container: str, server: str):
assert (
container is not None
), "Failed to determine the container that is runnning the pipeline. There is probably a bug in server end."
logger.info(f"Fetching logs from {container}")
for line in _fetch_logs(container, server=server):
print(line.decode().rstrip())
......@@ -188,7 +191,7 @@ def create_pipeline_from_command(cmd: str) -> Path:
return prepare_archive(pipeline_dir)
def submit_job(pipeline_zip: Path, *, server: str):
def submit_job(pipeline_zip: Path, *, server: str, rerun: bool = False):
"""Submit job to the API and stream the output."""
numbytes = pipeline_zip.stat().st_size
if (code := _check_server_status(server)) != 200:
......@@ -208,9 +211,9 @@ def submit_job(pipeline_zip: Path, *, server: str):
with pipeline_zip.open("rb") as f_pipeline:
files = {"pipeline_zip": f_pipeline}
response = g_session.post(
f"{server}/submit",
f"{server}/submit/?rerun={rerun}",
files=files,
data=dict(filename=pipeline_zip),
data=dict(filename=pipeline_zip, rerun=rerun),
)
return response.json()
......
......@@ -11,6 +11,8 @@ def test_sanity():
def test_run_simple():
output = bitia.__main__.run_pipeline("ls -ltr /")
print(output)
output = bitia.__main__.run_pipeline("ls -ltr /", rerun=True)
print(output)
if __name__ == "__main__":
......
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