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
0c8674be
Commit
0c8674be
authored
2 years ago
by
Nitish Kumar
Browse files
Options
Downloads
Patches
Plain Diff
added ui command
parent
1b3a74f6
No related branches found
Branches containing commit
No related tags found
1 merge request
!22
Draft: first raw iteration of bitia-cli frontend
Pipeline
#6341
failed with stages
Stage:
Stage:
in 1 minute and 6 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
bitia/__main__.py
+25
-5
25 additions, 5 deletions
bitia/__main__.py
bitia/common.py
+12
-0
12 additions, 0 deletions
bitia/common.py
with
37 additions
and
5 deletions
bitia/__main__.py
+
25
−
5
View file @
0c8674be
...
...
@@ -10,7 +10,10 @@ import os
import
functools
from
enum
import
Enum
import
subprocess
import
uvicorn
import
multiprocessing
from
fastapi
import
FastAPI
from
fastapi.staticfiles
import
StaticFiles
from
fastapi.middleware.cors
import
CORSMiddleware
from
rich.progress
import
track
...
...
@@ -18,6 +21,7 @@ from pathlib import Path
import
bitia.helper
as
bhelper
from
bitia.logger
import
logger
,
cprint
,
set_logger_level
,
console
from
bitia.common
import
find_unused_port
from
bitia
import
version
as
bversion
import
bitia.pipeline
as
bpipeline
...
...
@@ -30,10 +34,7 @@ import typer
app
=
typer
.
Typer
()
app_cli
=
FastAPI
()
origins
=
[
"
http://localhost:3000
"
,
"
http://localhost:8000
"
,
]
origins
=
[
"
*
"
,]
app_cli
.
add_middleware
(
CORSMiddleware
,
...
...
@@ -43,6 +44,9 @@ app_cli.add_middleware(
allow_headers
=
[
"
*
"
],
)
# static_dir = "dist"
# app_cli.mount("/", StaticFiles(directory=static_dir, html=True,))
class
VerbosityLevel
(
str
,
Enum
):
debug
=
"
debug
"
info
=
"
info
"
...
...
@@ -237,12 +241,28 @@ def version():
cprint
(
bversion
())
return
bversion
()
def
_run_server
():
host
=
"
127.0.0.1
"
start_port
=
8000
unused_port
=
find_unused_port
(
start_port
)
assert
unused_port
is
not
None
process
=
multiprocessing
.
Process
(
target
=
uvicorn
.
run
,
args
=
(
'
bitia.__main__:app_cli
'
,),
kwargs
=
{
"
host
"
:
host
,
"
port
"
:
unused_port
})
process
.
start
()
@app.command
()
def
ui
():
"""
spin up a frontend server for the cli
"""
parent_dir
=
Path
(
__file__
).
parent
.
parent
ui_path
=
parent_dir
/
'
new-ui
'
# run the bitia server
_run_server
()
# run the frontend
ui_path
=
parent_dir
/
'
sv-ui
'
subprocess
.
run
([
'
npm
'
,
'
run
'
,
'
dev
'
],
cwd
=
ui_path
)
if
__name__
==
"
__main__
"
:
app
()
This diff is collapsed.
Click to expand it.
bitia/common.py
+
12
−
0
View file @
0c8674be
from
pathlib
import
Path
from
enum
import
Enum
import
psutil
import
socket
from
typing
import
Optional
from
bitia.logger
import
logger
from
bitia.checksumdir
import
filehash
...
...
@@ -20,3 +23,12 @@ def dir_info(user_dir: Path) -> dict:
"
You should try to reduce the size of the pipeline. TODO: See this link.
"
)
return
dict
(
size_in_mb
=
size_in_mb
,
num_files
=
len
(
files
),
files
=
files
)
def
find_unused_port
(
after_port
:
int
)
->
Optional
[
int
]:
connections
=
psutil
.
net_connections
()
tcp_listeners
=
[
conn
for
conn
in
connections
if
conn
.
status
==
'
LISTEN
'
and
conn
.
type
==
socket
.
SOCK_STREAM
]
used_ports
=
[
conn
.
laddr
.
port
for
conn
in
tcp_listeners
]
for
port
in
range
(
after_port
+
1
,
65535
):
if
port
not
in
used_ports
:
return
port
return
None
\ No newline at end of file
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