Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
beat.editor
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
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
beat
beat.editor
Commits
b8120f50
Commit
b8120f50
authored
6 years ago
by
Samuel GAIST
Browse files
Options
Downloads
Patches
Plain Diff
[scripts][editor_cli] Implement editor start for specific asset
Part of
#186
Replaces
!51
parent
7d2a4b5f
No related branches found
No related tags found
1 merge request
!62
Core implementation
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
beat/editor/scripts/editor_cli.py
+61
-25
61 additions, 25 deletions
beat/editor/scripts/editor_cli.py
with
61 additions
and
25 deletions
beat/editor/scripts/editor_cli.py
+
61
−
25
View file @
b8120f50
...
...
@@ -35,6 +35,7 @@ import click
import
pkg_resources
from
click_plugins
import
with_plugins
from
PyQt5.QtWidgets
import
QApplication
from
PyQt5.QtCore
import
QCoreApplication
...
...
@@ -45,23 +46,21 @@ from beat.cmdline.decorators import verbosity_option
from
..utils
import
setup_logger
from
..widgets.mainwindow
import
MainWindow
from
..widgets.assetwidget
import
AssetWidget
from
..backend.assetmodel
import
AssetType
global
logger
logger
=
None
EPILOG
=
"""
\b
START_
EPILOG
=
"""
\b
Example:
$ beat editor start
"""
"""
@with_plugins
(
pkg_resources
.
iter_entry_points
(
"
beat.editor.cli
"
))
@click.group
(
cls
=
AliasedGroup
)
@click.pass_context
def
editor
(
ctx
):
"""
beat.editor commands.
"""
pass
@editor.command
(
epilog
=
EPILOG
)
@click.option
(
"
--prefix
"
,
"
-p
"
,
...
...
@@ -76,35 +75,72 @@ def editor(ctx):
)
@verbosity_option
()
@click.pass_context
def
editor
(
ctx
,
prefix
,
cache
):
"""
beat.editor commands.
"""
ctx
.
meta
[
"
prefix
"
]
=
prefix
ctx
.
meta
[
"
cache
"
]
=
cache
global
logger
logger
=
setup_logger
(
"
beat.editor
"
,
ctx
.
meta
[
"
verbosity
"
])
QCoreApplication
.
setApplicationName
(
"
beat.editor
"
)
QCoreApplication
.
setOrganizationName
(
"
Idiap
"
)
QCoreApplication
.
setOrganizationDomain
(
"
ch.idiap
"
)
@editor.command
(
epilog
=
START_EPILOG
)
@click.pass_context
@raise_on_error
def
start
(
ctx
,
prefix
,
cache
):
def
start
(
ctx
):
"""
Start the beat editor
"""
ctx
.
meta
[
"
prefix
"
]
=
prefix
ctx
.
meta
[
"
cache
"
]
=
cache
config
=
Configuration
(
ctx
.
meta
)
global
logger
logger
.
info
(
"
BEAT prefix set to `%s
'"
,
config
.
path
)
logger
.
info
(
"
BEAT cache set to `%s
'"
,
config
.
cache
)
completions
=
dict
(
prog
=
os
.
path
.
basename
(
sys
.
argv
[
0
]),
version
=
pkg_resources
.
require
(
"
beat.editor
"
)[
0
].
version
,
)
app
=
QApplication
(
sys
.
argv
)
completions
.
update
(
Configuration
({}).
as_dict
())
mainwindow
=
MainWindow
()
mainwindow
.
set_prefix_root
(
os
.
path
.
abspath
(
config
.
path
))
mainwindow
.
show
()
return
app
.
exec_
()
EDIT_EPILOG
=
"""
\b
Example:
$ beat editor edit algorithm user/my_algo/1
"""
# Check that we are in a BEAT working folder
logger
=
setup_logger
(
"
beat.editor
"
,
ctx
.
meta
[
"
verbosity
"
])
@editor.command
(
epilog
=
EDIT_EPILOG
)
@click.argument
(
"
asset_type
"
)
@click.argument
(
"
asset_name
"
)
@click.pass_context
@raise_on_error
def
edit
(
ctx
,
asset_type
,
asset_name
):
"""
Edit one specific asset
"""
config
=
Configuration
(
ctx
.
meta
)
global
logger
logger
.
info
(
"
BEAT prefix set to `%s
'"
,
config
.
path
)
logger
.
info
(
"
BEAT cache set to `%s
'"
,
config
.
cache
)
prefix_root
=
os
.
path
.
abspath
(
config
.
path
)
app
=
QApplication
(
sys
.
argv
)
QCoreApplication
.
setApplicationName
(
"
beat.editor
"
)
QCoreApplication
.
setOrganizationName
(
"
Idiap
"
)
QCoreApplication
.
setOrganizationDomain
(
"
ch.idiap
"
)
asset_widget
=
AssetWidget
()
asset_widget
.
set_prefix_root
(
prefix_root
)
asset_path
=
os
.
path
.
join
(
prefix_root
,
AssetType
.
path
(
AssetType
[
asset_type
.
upper
()]),
asset_name
+
"
.json
"
)
asset_widget
.
load_json
(
asset_path
)
asset_widget
.
show
()
mainwindow
=
MainWindow
()
mainwindow
.
set_prefix_root
(
config
.
path
)
mainwindow
.
show
()
return
app
.
exec_
()
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