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
e7810cdb
Commit
e7810cdb
authored
2 years ago
by
dilawar
Browse files
Options
Downloads
Patches
Plain Diff
feat: --versbose and --server are options
parent
d13dd449
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!2
version 0.2.0
Pipeline
#3721
failed with stages
Stage:
Stage:
in 1 minute and 42 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
Makefile
+1
-4
1 addition, 4 deletions
Makefile
bitia/__main__.py
+32
-17
32 additions, 17 deletions
bitia/__main__.py
bitia/config.py
+13
-1
13 additions, 1 deletion
bitia/config.py
with
46 additions
and
22 deletions
Makefile
+
1
−
4
View file @
e7810cdb
...
...
@@ -30,9 +30,6 @@ gr runner gitlab-runner:
gitlab-runner
exec
docker
test
gitlab-runner
exec
docker deploy
test_pipeline
:
install
$(
POETRY
)
run bitia_runner run tests/test_20220727
release
:
rm
-rf
dist/
*
.whl
bash ./.ci/realese.sh
...
...
@@ -41,5 +38,5 @@ doc html:
cd
docs
&&
make html
.PHONY
:
copr fix test install lint build
\
all check
test_pipeline
\
all check
\
runner gitlab-runner image image_upload
This diff is collapsed.
Click to expand it.
bitia/__main__.py
+
32
−
17
View file @
e7810cdb
...
...
@@ -6,6 +6,7 @@ https://bitia.link
"""
import
typing
as
T
import
os
import
functools
import
bitia.helper
as
bhelper
...
...
@@ -42,16 +43,14 @@ def session(func):
@app.command
(
"
create-container
"
)
@session
def
create_remote_container
(
user_input
:
str
,
recreate
:
bool
=
False
,
server
:
str
=
bconfig
.
DEFAULT_SERVER
):
def
create_remote_container
(
user_input
:
str
,
recreate
:
bool
=
False
):
"""
Run a pipeline
"""
pipeline_zip
,
_
=
bhelper
.
user_input_to_pipeline
(
user_input
)
res
=
bhelper
.
post_pipeline_task
(
pipeline_zip
,
server
=
server
,
endpoint
=
"
container/create
"
,
params
=
dict
(
recreate
=
"
true
"
if
recreate
else
"
false
"
),
server
=
bconfig
.
server
(),
stream
=
True
,
)
res
.
raise_for_status
()
...
...
@@ -62,15 +61,15 @@ def create_remote_container(
@app.command
(
"
list-container
"
)
@session
def
list_remote_container
(
user_input
:
str
,
server
:
str
=
bconfig
.
DEFAULT_SERVER
user_input
:
str
,
server
:
str
=
bconfig
.
g_server
)
->
T
.
List
[
str
]:
"""
List the remote server associated with the pipeline.
"""
_
,
pipeline_hash
=
bhelper
.
user_input_to_pipeline
(
user_input
)
logger
.
info
(
f
"
Finding container for
{
user_input
}
, sha256sum=
{
pipeline_hash
}
"
)
res
=
bhelper
.
get
(
endpoint
=
"
container/list
"
,
server
=
bconfig
.
server
(),
params
=
dict
(
pipeline_sha256
=
pipeline_hash
),
server
=
server
,
)
res
.
raise_for_status
()
_json
=
res
.
json
()
...
...
@@ -80,14 +79,14 @@ def list_remote_container(
@app.command
(
"
logs
"
)
@session
def
stream_log
(
user_input
:
str
,
server
:
str
=
bconfig
.
DEFAULT_SERVER
)
->
T
.
List
[
str
]
:
def
stream_log
(
user_input
:
str
,
server
:
str
=
bconfig
.
g_server
)
:
"""
Stream logs for the most recent run of a given pipeline.
"""
_
,
pipeline_hash
=
bhelper
.
user_input_to_pipeline
(
user_input
)
logger
.
info
(
f
"
Finding container for
{
user_input
}
, sha256sum=
{
pipeline_hash
}
"
)
res
=
bhelper
.
get
(
endpoint
=
"
logs
"
,
params
=
dict
(
pipeline_sha256
=
pipeline_hash
),
server
=
server
,
server
=
bconfig
.
server
()
,
stream
=
True
,
)
res
.
raise_for_status
()
...
...
@@ -97,9 +96,7 @@ def stream_log(user_input: str, server: str = bconfig.DEFAULT_SERVER) -> T.List[
@app.command
(
"
submit
"
)
@session
def
submit_pipeline
(
user_input
:
str
,
rerun
:
bool
=
False
,
server
:
str
=
bconfig
.
DEFAULT_SERVER
):
def
submit_pipeline
(
user_input
:
str
,
rerun
:
bool
=
False
):
"""
Submit your pipelin (url, directory, zip_file).
Prepare the user directory to send to the server. User can also provide link
...
...
@@ -113,13 +110,31 @@ def submit_pipeline(
@app.command
(
"
run
"
)
@session
def
run_pipeline
(
user_input
:
str
,
*
,
rerun
:
bool
=
False
,
server
:
str
=
bconfig
.
DEFAULT_SERVER
):
def
run_pipeline
(
user_input
:
str
,
*
,
rerun
:
bool
=
False
):
"""
Run a pipeline
"""
create_remote_container
(
user_input
,
recreate
=
rerun
,
server
=
server
)
containers
=
list_remote_container
(
user_input
,
server
=
server
)
return
[
bhelper
.
log_container
(
container
,
server
=
server
)
for
container
in
containers
]
create_remote_container
(
user_input
,
recreate
=
rerun
)
containers
=
list_remote_container
(
user_input
)
return
[
bhelper
.
log_container
(
container
,
server
=
bconfig
.
server
())
for
container
in
containers
]
@app.callback
()
def
main
(
verbose
:
bool
=
False
,
server
:
T
.
Optional
[
str
]
=
None
):
"""
Callback
"""
if
verbose
:
logger
.
info
(
"
--verbose mode enabled
"
)
if
server
is
not
None
:
bconfig
.
set_server
(
server
)
elif
os
.
environ
.
get
(
"
BITIA_SERVER
"
)
is
not
None
:
bconfig
.
set_server
(
os
.
environ
[
"
BITIA_SERVER
"
])
else
:
pass
logger
.
info
(
f
"
Using server
{
bconfig
.
server
()
}
"
)
@app.command
()
...
...
This diff is collapsed.
Click to expand it.
bitia/config.py
+
13
−
1
View file @
e7810cdb
...
...
@@ -3,7 +3,8 @@ from pathlib import Path
import
tempfile
BITIA_MAIN_SCRIPT_NAME
:
T
.
Final
[
str
]
=
"
__main__.bitia.sh
"
DEFAULT_SERVER
:
T
.
Final
[
str
]
=
"
https://public.bitia.link/api/v1
"
g_server
=
"
https://public.bitia.link/api/v1
"
def
bitia_dir
()
->
Path
:
...
...
@@ -11,3 +12,14 @@ def bitia_dir() -> Path:
bdir
=
Path
(
tempfile
.
gettempdir
())
/
"
bitia
"
bdir
.
mkdir
(
parents
=
True
,
exist_ok
=
True
)
return
bdir
def
server
()
->
str
:
"""
Server to use
"""
return
g_server
def
set_server
(
server
:
str
):
"""
set bitia server
"""
global
g_server
g_server
=
server
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