Commit 243eff6d authored by Flavio TARSETTI's avatar Flavio TARSETTI
Browse files

Merge branch 'imports_cleanup' into 'master'

Imports cleanup

This merge request mainly separates the cleanup introduced by isort from future work.

See merge request !126
parents 2a61cf07 edba1956
Pipeline #39596 passed with stages
in 7 minutes and 47 seconds
[flake8]
max-line-length = 80
max-line-length = 88
select = B,C,E,F,W,T4,B9,B950
ignore = E501, W503, E203
[settings]
line_length=88
order_by_type=true
lines_between_types=1
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: https://github.com/timothycrosley/isort
rev: 4.3.21-2
hooks:
- id: isort
args: [-sl]
- repo: https://github.com/ambv/black
rev: stable
hooks:
......@@ -9,6 +14,8 @@ repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.0.0
hooks:
- id: check-ast
- id: check-case-conflict
- id: trailing-whitespace
- id: end-of-file-fixer
- id: debug-statements
......
include COPYING README.rst version.txt requirements.txt buildout.cfg
recursive-include doc conf.py *.rst *.png *.ico *.md
recursive-include beat/editor/templates *.jinja2
......@@ -24,15 +24,17 @@
###############################################################################
import importlib
from enum import Enum
from enum import unique
import simplejson as json
import beat.core
from enum import Enum, unique
from beat.backend.python import utils
from beat.core.schema import validate
from beat.cmdline import common
from beat.core.schema import validate
@unique
......
......@@ -25,15 +25,14 @@
import os
from PyQt5.QtCore import QStringListModel
from PyQt5.QtCore import pyqtProperty
from PyQt5.QtCore import pyqtSignal
from PyQt5.QtCore import pyqtSlot
from PyQt5.QtCore import pyqtProperty
from PyQt5.QtCore import QStringListModel
from ..utils import dataformat_basetypes
from .asset import AssetType
from .asset import Asset
from .asset import AssetType
class AssetModel(QStringListModel):
......
......@@ -23,10 +23,9 @@
# #
###############################################################################
from PyQt5.QtCore import Qt
from PyQt5.QtCore import QEvent
from PyQt5.QtCore import QObject
from PyQt5.QtCore import Qt
from PyQt5.QtWidgets import QAbstractSpinBox
from PyQt5.QtWidgets import QComboBox
......
......@@ -35,7 +35,6 @@ from .asset import Asset
from .asset import AssetType
from .assetmodel import AssetModel
PARAMETER_TYPE_KEY = "parameter_type"
DEFAULT_VALUE_KEY = "default_value"
EDITED_KEY = "edited"
......@@ -80,10 +79,13 @@ class ExperimentResources:
DATASET_TABLE = "CREATE TABLE datasets(name varchar, outputs integer)"
INSERT_DATASET = "INSERT INTO datasets(name, outputs) VALUES(?, ?)"
query = QSqlQuery()
for query_str in [ALGORITHM_TABLE_CLEANUP, QUEUE_TABLE_CLEANUP, DATASET_TABLE_CLEANUP]:
for query_str in [
ALGORITHM_TABLE_CLEANUP,
QUEUE_TABLE_CLEANUP,
DATASET_TABLE_CLEANUP,
]:
if not query.exec_(query_str):
raise RuntimeError(f"Failed to drop table: {query.lastError().text()}")
......
......@@ -35,27 +35,23 @@ import click
import pkg_resources
from click_plugins import with_plugins
from PyQt5.QtWidgets import QApplication
from PyQt5.QtCore import QCoreApplication
from PyQt5.QtWidgets import QApplication
from beat.cmdline import environments
from beat.cmdline.click_helper import AliasedGroup
from beat.cmdline.decorators import raise_on_error
from beat.cmdline.decorators import verbosity_option
from beat.cmdline import environments
from ..utils import setup_logger
from ..utils import check_prefix_folders
from ..utils import check_prefix_dataformats
from ..widgets.mainwindow import MainWindow
from ..widgets.assetwidget import AssetWidget
from ..backend.asset import AssetType
from .. import version
from ..backend.asset import Asset
from ..backend.asset import AssetType
from ..backend.eventfilters import MouseWheelFilter
from .. import version
from ..utils import check_prefix_dataformats
from ..utils import check_prefix_folders
from ..utils import setup_logger
from ..widgets.assetwidget import AssetWidget
from ..widgets.mainwindow import MainWindow
global logger
logger = None
......
# You may import any python packages that will be available in the environment
# you will run this algorithm in Environments can change based on the
# experiment's settings
{% for ref, lib in contents.uses.items() %}# Library "{{ lib }}" is available under "{{ ref }}"
{% endfor %}
class Algorithm:
# initialise fields to store cross-input data (e.g. machines,
# aggregations, etc.)
def __init__(self):
pass
{% if contents.parameters %}
# do initial setup work with the given parameters for the algorithm
def setup(self, parameters):
# Parameters available:
{% for p_name, param in contents.parameters.items() %}# Parameter "{{ p_name }}" with type "{{ param.type }}"
{% endfor %}
# get a parameter like:
# param1_value = parameters.get('param_1', self.param1_default)
return True
{% endif %}
# this will be called each time the sync'd input has more data available to
# be processed
def process(self, inputs, outputs):
# Groups available:
{% for group in contents.groups %} # Group {{ loop.index - 1 }}:
{% for iName, input in group.inputs.items() %}# Input "{{ iName }}" with type "{{ input.type }}"
{% endfor %}{% if 'outputs' in group %}{% for oName, output in group.outputs.items() %}# Output "{{ oName }}" with type "{{ output.type }}"
{% endfor %}{% endif %}{% endfor %}{% if 'splittable' not in contents %}
# Results available:
{% for rName, result in contents.results.items() %}# Result "{{ rName }}" with type "{{ result.type }}"
{% endfor %}{% endif %}
# to check if there is more data waiting in the inputs
# (if it is False, you have processed all the inputs and this "process"
# function won't be called again):
# if inputs.hasMoreData():
# to check if a specific input is done:
# if inputs["input1"].isDataUnitDone():
# to manually fetch the next input of a specific input
# (e.g. the block is not sync'd to the input but you want the input
# immediately)
# inputs['input1'].next()
# you can then access that input value as normal:
# self.val1 = inputs['input1'].data
# to get the data for an input (note that the value will be of the type
# specified in the metadata!):
# data_value = inputs['input1'].data
# to write to an output:
# outputs['output1'].write({
# 'output_field_1': 1,
# 'output_field_2': 'output'
# })
# always return True, it signals BEAT to continue processing
return True
# You may import any python packages that will be available in the environment
# you will run this database in Environments can change based on the
# experiment's settings
from beat.backend.python.database import View
{% for view in views %}
class {{ view }}(View):
# build the data for your view
# split the raw data into (homogenous) bits and return a keyed iterable
# (something with `.keys()` available to it, like a dict)
# the key names must be the same as the output names for sets that use this
# view.
# root_folder: the path to the root folder of the database's files (not
# always applicable)
# parameters: parameters passed to the view, defined in the metadata
def index(self, root_folder, parameters):
pass
# returns a value at a specific index in the iterable for this view
# output: the specific output value requested
# index: the current index of the iterable
def get(self, output, index):
# to get the current object referenced by the given index:
# obj = self.objs[index]
# note that this object is a named tuple, with fields equivalent to
# your keys from the objects returned from the index function
pass
{% endfor -%}
# You may import any python packages that will be available in the environment
# you will run this library in Environments can change based on the
# experiment's settings
{% for ref, lib in uses.items() %}# Library "{{ lib }}" is available under "{{ ref }}"
{% endfor -%}
# You may import any python packages that will be available in the environment you will run this plotter in
# Environments can change based on the experiment's settings
{% for ref, lib in uses.uses.items() %}# Library "{{ lib }}" is available under "{{ ref }}"
{% endfor %}
# Makes sure we won't require an X11 connection
import matplotlib
matplotlib.use('Agg')
import numpy
import itertools
class Plotter(baselib.Plotter):
{% if uses.parameters %}
# do initial setup work with the given parameters for the plotter
def setup(self, parameters):
super(Plotter, self).setup(parameters)
# Parameters available:
{% for p_name, param in uses.parameters.items() %}# Parameter "{{ p_name }}" with type "{{ param.type }}"
{% endfor %}
# get a parameter like:
# param1_value = parameters.get('param_1', self.param1_default)
return True
{% endif %}
# this will be called each time the sync'd input has more data available to be processed
def process(self, inputs):
fig, ax = super(Plotter, self).prepare_canvas()
# apply at the beginning of this function or before returning for needed modifications
super(Plotter, self).apply_parameters(ax)
# ax.set_title(self.title, fontdict={'fontsize':self.title_fontsize})
# ax.set_xlabel(self.xlabel, fontdict={'fontsize':self.axis_fontsize})
# ax.set_ylabel(self.ylabel, fontdict={'fontsize':self.axis_fontsize})
# ax.set_xlim((self.xlim_left,self.xlim_right))
# ax.set_ylim((self.ylim_bottom,self.ylim_top))
return super(Plotter, self).encode_figure(fig)
......@@ -23,18 +23,19 @@
# #
###############################################################################
import importlib
import os
import shutil
import subprocess
import sys
import tempfile
import pytest
import pkg_resources
import simplejson as json
import subprocess
import shutil
import importlib
from collections import namedtuple
import pkg_resources
import pytest
import simplejson as json
from beat.cmdline.config import Configuration
from ..backend.asset import AssetType
......
......@@ -32,20 +32,19 @@ from beat.backend.python.algorithm import Algorithm
from ..backend.asset import Asset
from ..backend.asset import AssetType
from ..backend.assetmodel import AssetModel
from ..widgets.algorithmeditor import PropertyEditor
from ..widgets.algorithmeditor import ParameterEditor
from ..widgets.algorithmeditor import ResultEditor
from ..widgets.algorithmeditor import IOWidget
from ..widgets.algorithmeditor import GroupEditor
from ..widgets.algorithmeditor import AlgorithmEditor
from ..widgets.algorithmeditor import ALGORITHM_TYPE
from ..widgets.algorithmeditor import DEFAULT_SCHEMA_VERSION
from ..widgets.algorithmeditor import DEFAULT_API_VERSION
from ..widgets.algorithmeditor import DEFAULT_SCHEMA_VERSION
from ..widgets.algorithmeditor import AlgorithmEditor
from ..widgets.algorithmeditor import GroupEditor
from ..widgets.algorithmeditor import IOWidget
from ..widgets.algorithmeditor import ParameterEditor
from ..widgets.algorithmeditor import PropertyEditor
from ..widgets.algorithmeditor import ResultEditor
from ..widgets.algorithmeditor import migrate_to_api_v2
from ..widgets.algorithmeditor import update_code
from .conftest import sync_prefix
from .conftest import prefix
from .conftest import sync_prefix
def get_algorithm_declaration(prefix_path, algorithm_name):
......
......@@ -24,11 +24,12 @@
###############################################################################
import os
import pytest
import shutil
import simplejson as json
import tempfile
import pytest
import simplejson as json
from ..backend.asset import Asset
from ..backend.asset import AssetType
......
......@@ -25,8 +25,8 @@
from PyQt5.QtCore import Qt
from ..backend.asset import AssetType
from ..backend.asset import Asset
from ..backend.asset import AssetType
from ..widgets.assetbrowser import AssetBrowser
......
......@@ -24,10 +24,11 @@
###############################################################################
import os
import pytest
from ..backend.assetmodel import AssetModel
from ..backend.asset import AssetType
from ..backend.assetmodel import AssetModel
from ..utils import dataformat_basetypes
......
......@@ -24,32 +24,29 @@
###############################################################################
import os
import pytest
import random
from PyQt5 import QtCore
import pytest
from PyQt5 import QtCore
from PyQt5.QtWidgets import QMessageBox
from ..backend.asset import Asset
from ..backend.asset import AssetType
from ..backend.assetmodel import AssetModel
from ..widgets.algorithmeditor import AlgorithmEditor
from ..widgets.assetwidget import AssetWidget
from ..widgets.assetwidget import widget_for_asset_type
from ..widgets.dialogs import AssetCreationDialog
from ..widgets.editor import PlaceholderEditor
from ..widgets.algorithmeditor import AlgorithmEditor
from ..widgets.databaseeditor import DatabaseEditor
from ..widgets.dataformateditor import DataformatEditor
from ..widgets.dialogs import AssetCreationDialog
from ..widgets.editor import PlaceholderEditor
from ..widgets.experimenteditor import ExperimentEditor
from ..widgets.libraryeditor import LibraryEditor
from ..widgets.plottereditor import PlotterEditor
from ..widgets.plotterparameterseditor import PlotterParametersEditor
from ..widgets.protocoltemplateeditor import ProtocolTemplateEditor
from ..widgets.toolchaineditor import ToolchainEditor
from ..backend.asset import AssetType
from ..backend.asset import Asset
from ..backend.assetmodel import AssetModel
from .conftest import sync_prefix
......
......@@ -24,22 +24,22 @@
###############################################################################
import copy
import pytest
from PyQt5 import QtCore
from PyQt5.QtWidgets import QComboBox
from PyQt5.QtWidgets import QInputDialog
from ..backend.asset import AssetType
from ..backend.asset import Asset
from ..backend.asset import AssetType
from ..widgets.databaseeditor import DatabaseEditor
from ..widgets.databaseeditor import ViewEditor
from ..widgets.databaseeditor import ViewsEditor
from ..widgets.databaseeditor import ProtocolEditor
from ..widgets.databaseeditor import DatabaseWidget
from ..widgets.databaseeditor import ParameterTypeDelegate
from ..widgets.databaseeditor import ProtocolDialog
from ..widgets.databaseeditor import ProtocolEditor
from ..widgets.databaseeditor import ViewEditor
from ..widgets.databaseeditor import ViewsEditor
@pytest.yield_fixture(params=[i for i in range(1, 3)])
......
Supports Markdown
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