Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
B
bitia-cli
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
1
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
bitia
bitia-cli
Commits
1313c1b1
Commit
1313c1b1
authored
2 years ago
by
dilawar
Browse files
Options
Downloads
Patches
Plain Diff
temp:
parent
6675447d
No related branches found
No related tags found
1 merge request
!2
version 0.2.0
Pipeline
#3701
failed with stages
in 2 minutes and 3 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
bitia/__main__.py
+10
-7
10 additions, 7 deletions
bitia/__main__.py
tests/test_sanity.py
+2
-0
2 additions, 0 deletions
tests/test_sanity.py
with
12 additions
and
7 deletions
bitia/__main__.py
+
10
−
7
View file @
1313c1b1
...
...
@@ -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
()
...
...
This diff is collapsed.
Click to expand it.
tests/test_sanity.py
+
2
−
0
View file @
1313c1b1
...
...
@@ -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__
"
:
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment