...
 
Commits (4)
......@@ -85,13 +85,6 @@ refresh_environment_cache_flag = click.option(
)
START_EPILOG = """\b
Example:
$ beat editor start
"""
@with_plugins(pkg_resources.iter_entry_points("beat.editor.cli"))
@click.group(cls=AliasedGroup)
@click.option(
......@@ -124,7 +117,13 @@ def editor(ctx, environments):
QCoreApplication.setApplicationVersion(version.__version__)
@editor.command(epilog=START_EPILOG)
@editor.command(
epilog="""\b
Example:
$ beat editor start
"""
)
@click.pass_context
@refresh_environment_cache_flag
@raise_on_error
......@@ -146,14 +145,13 @@ def start(ctx):
return app.exec_()
EDIT_EPILOG = """\b
@editor.command(
epilog="""\b
Example:
$ beat editor edit algorithm user/my_algo/1
"""
@editor.command(epilog=EDIT_EPILOG)
)
@click.argument("asset_type")
@click.argument("asset_name")
@click.pass_context
......@@ -176,14 +174,13 @@ def edit(ctx, asset_type, asset_name):
return app.exec_()
ENV_REFRESH_EPILOG = """\b
@editor.command(
epilog="""\b
Example:
$ beat editor refresh_env
"""
@editor.command(epilog=ENV_REFRESH_EPILOG)
)
@click.option(
"--type",
"-t",
......
......@@ -23,6 +23,10 @@
# #
###############################################################################
import logging
import numpy as np
from PyQt5.QtCore import Qt
from PyQt5.QtCore import QTimer
from PyQt5.QtCore import pyqtSignal
......@@ -50,6 +54,8 @@ from .parameterwidget import InputType
from .scrollwidget import ScrollWidget
from .spinboxes import NumpySpinBox
logger = logging.getLogger(__name__)
class ParameterChoiceDialog(QDialog):
"""Dialog to retrieve a value to to add to the editable parameters"""
......@@ -120,7 +126,17 @@ class RestrictedParameterWidget(QWidget):
super().__init__(parent)
self._type = data.get("type", None)
self.default = data.get("default", None)
default = data.get("default", "" if self._type == "string" else 0)
# cast the default value to the required type
cast_fn = np.cast[self._type] if self._type != "string" else str
try:
default = cast_fn(default)
except ValueError:
logger.exception(
f"Failed to convert the default value: {default} to type {self._type}",
)
default = cast_fn("" if self._type == "string" else 0)
self.default = default
self.current_type = InputType[self._type.upper()]
self.modality = "single"
......