Commit 74be05b1 authored by Samuel GAIST's avatar Samuel GAIST

[cmdline] Pre-commit cleanup

parent 33320a6b
...@@ -59,41 +59,41 @@ logger = logging.getLogger(__name__) ...@@ -59,41 +59,41 @@ logger = logging.getLogger(__name__)
def pull_impl(webapi, prefix, names, force, indentation, format_cache, lib_cache): def pull_impl(webapi, prefix, names, force, indentation, format_cache, lib_cache):
"""Copies algorithms (and required libraries/dataformats) from the server. """Copies algorithms (and required libraries/dataformats) from the server.
Parameters: Parameters:
webapi (object): An instance of our WebAPI class, prepared to access the webapi (object): An instance of our WebAPI class, prepared to access the
BEAT server of interest BEAT server of interest
prefix (str): A string representing the root of the path in which the user prefix (str): A string representing the root of the path in which the user
objects are stored objects are stored
names (:py:class:`list`): A list of strings, each representing the unique names (:py:class:`list`): A list of strings, each representing the unique
relative path of the objects to retrieve or a list of usernames from relative path of the objects to retrieve or a list of usernames from
which to retrieve objects. If the list is empty, then we pull all which to retrieve objects. If the list is empty, then we pull all
available objects of a given type. If no user is set, then pull all available objects of a given type. If no user is set, then pull all
public objects of a given type. public objects of a given type.
force (bool): If set to ``True``, then overwrites local changes with the force (bool): If set to ``True``, then overwrites local changes with the
remotely retrieved copies. remotely retrieved copies.
indentation (int): The indentation level, useful if this function is called indentation (int): The indentation level, useful if this function is called
recursively while downloading different object types. This is normally recursively while downloading different object types. This is normally
set to ``0`` (zero). set to ``0`` (zero).
format_cache (dict): A dictionary containing all dataformats already format_cache (dict): A dictionary containing all dataformats already
downloaded. downloaded.
lib_cache (dict): A dictionary containing all libraries already lib_cache (dict): A dictionary containing all libraries already
downloaded. downloaded.
Returns: Returns:
int: Indicating the exit status of the command, to be reported back to the int: Indicating the exit status of the command, to be reported back to the
calling process. This value should be zero if everything works OK, calling process. This value should be zero if everything works OK,
otherwise, different than zero (POSIX compliance). otherwise, different than zero (POSIX compliance).
""" """
from .dataformats import pull_impl as dataformats_pull from .dataformats import pull_impl as dataformats_pull
from .libraries import pull_impl as libraries_pull from .libraries import pull_impl as libraries_pull
...@@ -384,9 +384,9 @@ commands.initialise_asset_commands(algorithms, CMD_LIST, AlgorithmCommand) ...@@ -384,9 +384,9 @@ commands.initialise_asset_commands(algorithms, CMD_LIST, AlgorithmCommand)
def pull(ctx, name, force): def pull(ctx, name, force):
"""Downloads the specified algorithms from the server """Downloads the specified algorithms from the server
Example: Example:
$ beat algorithms pull --force yyy $ beat algorithms pull --force yyy
""" """
with common.make_webapi(ctx.meta["config"]) as webapi: with common.make_webapi(ctx.meta["config"]) as webapi:
return pull_impl(webapi, ctx.meta["config"].path, name, force, 0, {}, {}) return pull_impl(webapi, ctx.meta["config"].path, name, force, 0, {}, {})
...@@ -401,10 +401,10 @@ def pull(ctx, name, force): ...@@ -401,10 +401,10 @@ def pull(ctx, name, force):
def execute(ctx, instructions, example): def execute(ctx, instructions, example):
"""Execute an algorithm following instructions in a JSON file """Execute an algorithm following instructions in a JSON file
Example: Example:
$ beat algorithms execute <instructions> $ beat algorithms execute <instructions>
$ beat algorithms execute --examples $ beat algorithms execute --examples
""" """
if example: if example:
print_examples() print_examples()
return 0 return 0
......
...@@ -89,8 +89,8 @@ class MutuallyExclusiveOption(click.Option): ...@@ -89,8 +89,8 @@ class MutuallyExclusiveOption(click.Option):
class AssetInfo: class AssetInfo:
""" Information needed by the command to properly call local and remote """Information needed by the command to properly call local and remote
commands commands
""" """
def __init__( def __init__(
...@@ -108,8 +108,8 @@ class AssetInfo: ...@@ -108,8 +108,8 @@ class AssetInfo:
class AssetCommand(click.Command): class AssetCommand(click.Command):
""" Custom click command that will update the context with asset information """Custom click command that will update the context with asset information
related to the command called. related to the command called.
""" """
asset_info = AssetInfo() asset_info = AssetInfo()
......
...@@ -88,9 +88,9 @@ def list_impl(ctx, remote): ...@@ -88,9 +88,9 @@ def list_impl(ctx, remote):
def path_impl(ctx, names): def path_impl(ctx, names):
"""Displays local path of asset files """Displays local path of asset files
Example: Example:
$ beat <asset_type> path xxx $ beat <asset_type> path xxx
""" """
config = ctx.meta["config"] config = ctx.meta["config"]
asset_info = ctx.meta["asset_info"] asset_info = ctx.meta["asset_info"]
...@@ -104,9 +104,9 @@ def path_impl(ctx, names): ...@@ -104,9 +104,9 @@ def path_impl(ctx, names):
def edit_impl(ctx, name): def edit_impl(ctx, name):
"""Edit local asset file """Edit local asset file
Example: Example:
$ beat <asset_type> edit xxx $ beat <asset_type> edit xxx
""" """
config = ctx.meta["config"] config = ctx.meta["config"]
asset_info = ctx.meta["asset_info"] asset_info = ctx.meta["asset_info"]
...@@ -135,9 +135,9 @@ def check_impl(ctx, names): ...@@ -135,9 +135,9 @@ def check_impl(ctx, names):
def status_impl(ctx): def status_impl(ctx):
"""Shows (editing) status for all available items of asset type """Shows (editing) status for all available items of asset type
Example: Example:
$ beat <asset_type> status $ beat <asset_type> status
""" """
config = ctx.meta["config"] config = ctx.meta["config"]
asset_info = ctx.meta["asset_info"] asset_info = ctx.meta["asset_info"]
......
This diff is collapsed.
...@@ -53,42 +53,42 @@ logger = logging.getLogger(__name__) ...@@ -53,42 +53,42 @@ logger = logging.getLogger(__name__)
def pull_impl(webapi, prefix, names, force, indentation, cache): def pull_impl(webapi, prefix, names, force, indentation, cache):
"""Copies dataformats (recursively) from the server. """Copies dataformats (recursively) from the server.
Data formats are particularly tricky to download because of their recursive Data formats are particularly tricky to download because of their recursive
nature. This requires a specialized recursive technique to download base and nature. This requires a specialized recursive technique to download base and
referenced dataformats. referenced dataformats.
Parameters: Parameters:
webapi (object): An instance of our WebAPI class, prepared to access the webapi (object): An instance of our WebAPI class, prepared to access the
BEAT server of interest BEAT server of interest
prefix (str): A string representing the root of the path in which the user prefix (str): A string representing the root of the path in which the user
objects are stored objects are stored
names (:py:class:`list`): A list of strings, each representing the unique names (:py:class:`list`): A list of strings, each representing the unique
relative path of the objects to retrieve or a list of usernames from relative path of the objects to retrieve or a list of usernames from
which to retrieve objects. If the list is empty, then we pull all which to retrieve objects. If the list is empty, then we pull all
available objects of a given type. If no user is set, then pull all available objects of a given type. If no user is set, then pull all
public objects of a given type. public objects of a given type.
force (bool): If set to ``True``, then overwrites local changes with the force (bool): If set to ``True``, then overwrites local changes with the
remotely retrieved copies. remotely retrieved copies.
indentation (int): The indentation level, useful if this function is called indentation (int): The indentation level, useful if this function is called
recursively while downloading different object types. This is normally recursively while downloading different object types. This is normally
set to ``0`` (zero). set to ``0`` (zero).
cache (dict): A dictionary containing all dataformats already downloaded. cache (dict): A dictionary containing all dataformats already downloaded.
Returns: Returns:
int: Indicating the exit status of the command, to be reported back to the int: Indicating the exit status of the command, to be reported back to the
calling process. This value should be zero if everything works OK, calling process. This value should be zero if everything works OK,
otherwise, different than zero (POSIX compliance). otherwise, different than zero (POSIX compliance).
""" """
dataformats = set(names) # what is being request dataformats = set(names) # what is being request
download = dataformats - set(cache.keys()) # what we actually need download = dataformats - set(cache.keys()) # what we actually need
...@@ -187,9 +187,9 @@ commands.initialise_asset_commands(dataformats, CMD_LIST, DataformatCommand) ...@@ -187,9 +187,9 @@ commands.initialise_asset_commands(dataformats, CMD_LIST, DataformatCommand)
def pull(ctx, name, force): def pull(ctx, name, force):
"""Downloads the specified dataformats from the server """Downloads the specified dataformats from the server
Example: Example:
$ beat dataformats pull --force yyy $ beat dataformats pull --force yyy
""" """
with common.make_webapi(ctx.meta["config"]) as webapi: with common.make_webapi(ctx.meta["config"]) as webapi:
name = common.make_up_remote_list(webapi, "dataformat", name) name = common.make_up_remote_list(webapi, "dataformat", name)
if name is None: if name is None:
......
...@@ -44,6 +44,7 @@ import signal ...@@ -44,6 +44,7 @@ import signal
import textwrap import textwrap
import threading import threading
import traceback import traceback
from datetime import timedelta from datetime import timedelta
import click import click
...@@ -602,7 +603,7 @@ def plot_impl(configuration, names, remote, show, output_folder, plotterparamete ...@@ -602,7 +603,7 @@ def plot_impl(configuration, names, remote, show, output_folder, plotterparamete
data_to_plot[name] = cleaned_data data_to_plot[name] = cleaned_data
def _get_plotter_for(dataformat): def _get_plotter_for(dataformat):
""" Returns the first plotter that matches the dataformat given in """Returns the first plotter that matches the dataformat given in
parameter. parameter.
""" """
...@@ -812,7 +813,7 @@ def caches(ctx, name, list, delete, checksum): ...@@ -812,7 +813,7 @@ def caches(ctx, name, list, delete, checksum):
def pull(ctx, names, force): def pull(ctx, names, force):
"""Downloads the specified experiments from the server. """Downloads the specified experiments from the server.
$ beat experiments pull xxx. $ beat experiments pull xxx.
""" """
config = ctx.meta.get("config") config = ctx.meta.get("config")
with common.make_webapi(config) as webapi: with common.make_webapi(config) as webapi:
......
...@@ -92,37 +92,37 @@ logger = logging.getLogger(__name__) ...@@ -92,37 +92,37 @@ logger = logging.getLogger(__name__)
def pull_impl(webapi, prefix, names, force, indentation, cache): def pull_impl(webapi, prefix, names, force, indentation, cache):
"""Copies libraries (and dependent libraries) from the server. """Copies libraries (and dependent libraries) from the server.
Parameters: Parameters:
webapi (object): An instance of our WebAPI class, prepared to access the webapi (object): An instance of our WebAPI class, prepared to access the
BEAT server of interest BEAT server of interest
prefix (str): A string representing the root of the path in which the user prefix (str): A string representing the root of the path in which the user
objects are stored objects are stored
names (:py:class:`list`): A list of strings, each representing the unique names (:py:class:`list`): A list of strings, each representing the unique
relative path of the objects to retrieve or a list of usernames from relative path of the objects to retrieve or a list of usernames from
which to retrieve objects. If the list is empty, then we pull all which to retrieve objects. If the list is empty, then we pull all
available objects of a given type. If no user is set, then pull all available objects of a given type. If no user is set, then pull all
public objects of a given type. public objects of a given type.
force (bool): If set to ``True``, then overwrites local changes with the force (bool): If set to ``True``, then overwrites local changes with the
remotely retrieved copies. remotely retrieved copies.
indentation (int): The indentation level, useful if this function is called indentation (int): The indentation level, useful if this function is called
recursively while downloading different object types. This is normally recursively while downloading different object types. This is normally
set to ``0`` (zero). set to ``0`` (zero).
cache (dict): A dictionary containing all libraries already downloaded. cache (dict): A dictionary containing all libraries already downloaded.
Returns: Returns:
int: Indicating the exit status of the command, to be reported back to the int: Indicating the exit status of the command, to be reported back to the
calling process. This value should be zero if everything works OK, calling process. This value should be zero if everything works OK,
otherwise, different than zero (POSIX compliance). otherwise, different than zero (POSIX compliance).
""" """
libraries = set(names) # what is being request libraries = set(names) # what is being request
download = libraries - set(cache.keys()) # what we actually need download = libraries - set(cache.keys()) # what we actually need
...@@ -220,8 +220,8 @@ commands.initialise_asset_commands(libraries, CMD_LIST, LibraryCommand) ...@@ -220,8 +220,8 @@ commands.initialise_asset_commands(libraries, CMD_LIST, LibraryCommand)
def pull(ctx, names, force): def pull(ctx, names, force):
"""Downloads the specified libraries from the server """Downloads the specified libraries from the server
Example: Example:
$ beat libraries pull --force yyy $ beat libraries pull --force yyy
""" """
with common.make_webapi(ctx.meta["config"]) as webapi: with common.make_webapi(ctx.meta["config"]) as webapi:
return pull_impl(webapi, ctx.meta["config"].path, names, force, 0, {}) return pull_impl(webapi, ctx.meta["config"].path, names, force, 0, {})
...@@ -126,7 +126,7 @@ commands.initialise_asset_commands( ...@@ -126,7 +126,7 @@ commands.initialise_asset_commands(
def pull(ctx, names, force): def pull(ctx, names, force):
"""Downloads the specified plotterparameters from the server. """Downloads the specified plotterparameters from the server.
$ beat plotterparameters pull xxx. $ beat plotterparameters pull xxx.
""" """
with common.make_webapi(ctx.meta["config"]) as webapi: with common.make_webapi(ctx.meta["config"]) as webapi:
name = common.make_up_remote_list(webapi, "plotterparameter", names) name = common.make_up_remote_list(webapi, "plotterparameter", names)
......
...@@ -346,7 +346,7 @@ commands.initialise_asset_commands(plotters, CMD_LIST, PlotterCommand) ...@@ -346,7 +346,7 @@ commands.initialise_asset_commands(plotters, CMD_LIST, PlotterCommand)
def pull(ctx, names, force): def pull(ctx, names, force):
"""Downloads the specified plotters from the server. """Downloads the specified plotters from the server.
$ beat plotters pull xxx. $ beat plotters pull xxx.
""" """
with common.make_webapi(ctx.meta["config"]) as webapi: with common.make_webapi(ctx.meta["config"]) as webapi:
name = common.make_up_remote_list(webapi, "plotter", names) name = common.make_up_remote_list(webapi, "plotter", names)
...@@ -372,9 +372,9 @@ def plot( ...@@ -372,9 +372,9 @@ def plot(
): ):
"""Plots an image. """Plots an image.
$ beat plotters plot [--show] [--force] [--sample_data] $ beat plotters plot [--show] [--force] [--sample_data]
[--input-data=<filename.json>] [--output-image=<filename.png>] [--input-data=<filename.json>] [--output-image=<filename.png>]
[--plotter-parameter=<plotterparameter>] [<name>]... [--plotter-parameter=<plotterparameter>] [<name>]...
""" """
with common.make_webapi(ctx.meta["config"]) as webapi: with common.make_webapi(ctx.meta["config"]) as webapi:
return plot_impl( return plot_impl(
......
...@@ -85,7 +85,7 @@ commands.initialise_asset_commands(toolchains, CMD_LIST, ToolchainCommand) ...@@ -85,7 +85,7 @@ commands.initialise_asset_commands(toolchains, CMD_LIST, ToolchainCommand)
def pull(ctx, names, force): def pull(ctx, names, force):
"""Downloads the specified toolchains from the server. """Downloads the specified toolchains from the server.
$ beat toolchains pull xxx. $ beat toolchains pull xxx.
""" """
with common.make_webapi(ctx.meta["config"]) as webapi: with common.make_webapi(ctx.meta["config"]) as webapi:
status, downloaded = common.pull( status, downloaded = common.pull(
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment