Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python3: use @six.add_metaclass() decorator #3491

Merged
merged 1 commit into from Jan 26, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
23 changes: 3 additions & 20 deletions .ci/flake8_lint_include_list.txt
Expand Up @@ -14,6 +14,7 @@ lib/galaxy/dataset_collections/__init__.py
lib/galaxy/dataset_collections/structure.py
lib/galaxy/dataset_collections/subcollections.py
lib/galaxy/dataset_collections/type_description.py
lib/galaxy/dataset_collections/types/__init__.py
lib/galaxy/datatypes/assembly.py
lib/galaxy/datatypes/binary.py
lib/galaxy/datatypes/checkers.py
Expand Down Expand Up @@ -93,16 +94,7 @@ lib/galaxy/jobs/runners/pulsar.py
lib/galaxy/jobs/runners/slurm.py
lib/galaxy/jobs/runners/state_handlers/
lib/galaxy/jobs/runners/tasks.py
lib/galaxy/jobs/runners/util/cli/factory.py
lib/galaxy/jobs/runners/util/cli/job/__init__.py
lib/galaxy/jobs/runners/util/cli/job/slurm_torque.py
lib/galaxy/jobs/runners/util/cli/job/torque.py
lib/galaxy/jobs/runners/util/cli/shell/__init__.py
lib/galaxy/jobs/runners/util/drmaa/
lib/galaxy/jobs/runners/util/env.py
lib/galaxy/jobs/runners/util/external.py
lib/galaxy/jobs/runners/util/__init__.py
lib/galaxy/jobs/runners/util/job_script/
lib/galaxy/jobs/runners/util/
lib/galaxy/jobs/splitters/basic.py
lib/galaxy/jobs/splitters/__init__.py
lib/galaxy/jobs/stock_rules.py
Expand Down Expand Up @@ -266,16 +258,7 @@ lib/galaxy/security/validate_user_input.py
lib/galaxy/tags/
lib/galaxy/tools/
lib/galaxy/util/
lib/galaxy_utils/__init__.py
lib/galaxy/util/sleeper.py
lib/galaxy/util/specs.py
lib/galaxy_utils/sequence/fasta.py
lib/galaxy_utils/sequence/fastq.py
lib/galaxy_utils/sequence/__init__.py
lib/galaxy_utils/sequence/transform.py
lib/galaxy_utils/sequence/vcf.py
lib/galaxy/util/template.py
lib/galaxy/util/ucsc.py
lib/galaxy_utils/
lib/galaxy/version.py
lib/galaxy/visualization/data_providers/basic.py
lib/galaxy/visualization/data_providers/cigar.py
Expand Down
2 changes: 1 addition & 1 deletion .ci/py3_sources.txt
Expand Up @@ -65,7 +65,7 @@ lib/galaxy/webapps/tool_shed/util/ratings_util.py
lib/galaxy/work/
lib/galaxy/workflow/extract.py
lib/galaxy/workflow/run.py
lib/galaxy/workflow/schedulers/core.py
lib/galaxy/workflow/schedulers/
lib/galaxy/workflow/steps.py
lib/galaxy_ext/
lib/galaxy_utils/
Expand Down
5 changes: 3 additions & 2 deletions lib/galaxy/auth/providers/__init__.py
Expand Up @@ -3,13 +3,14 @@

@author: Andrew Robinson
"""

import abc

import six


@six.add_metaclass(abc.ABCMeta)
class AuthProvider(object):
"""A base class for all Auth Providers."""
__metaclass__ = abc.ABCMeta

@abc.abstractproperty
def plugin_type(self):
Expand Down
13 changes: 9 additions & 4 deletions lib/galaxy/dataset_collections/types/__init__.py
@@ -1,13 +1,18 @@
import logging
from abc import (
ABCMeta,
abstractmethod
)

import six

from galaxy import exceptions
from abc import ABCMeta
from abc import abstractmethod

import logging
log = logging.getLogger( __name__ )


@six.add_metaclass(ABCMeta)
class DatasetCollectionType(object):
__metaclass__ = ABCMeta

@abstractmethod
def generate_elements( self, dataset_instances ):
Expand Down
14 changes: 9 additions & 5 deletions lib/galaxy/jobs/datasets.py
Expand Up @@ -2,13 +2,17 @@
Utility classes allowing Job interface to reason about datasets.
"""
import os.path
from abc import ABCMeta
from abc import abstractmethod
from abc import (
ABCMeta,
abstractmethod
)

import six


def dataset_path_rewrites( dataset_paths ):
dataset_paths_with_rewrites = filter( lambda path: getattr( path, "false_path", None ), dataset_paths )
return dict( [ ( dp.real_path, dp ) for dp in dataset_paths_with_rewrites ] )
dataset_paths_with_rewrites = [path for path in dataset_paths if getattr(path, "false_path", None)]
return dict( ( dp.real_path, dp ) for dp in dataset_paths_with_rewrites )


class DatasetPath( object ):
Expand Down Expand Up @@ -49,9 +53,9 @@ def with_path_for_job( self, false_path, false_extra_files_path=None ):
return dataset_path


@six.add_metaclass(ABCMeta)
class DatasetPathRewriter( object ):
""" Used by runner to rewrite paths. """
__metaclass__ = ABCMeta

@abstractmethod
def rewrite_dataset_path( self, dataset, dataset_type ):
Expand Down
10 changes: 6 additions & 4 deletions lib/galaxy/jobs/metrics/instrumenters/__init__.py
Expand Up @@ -3,19 +3,21 @@
These are responsible for collecting and formatting a coherent set of metrics.
"""
import os.path
from abc import (
ABCMeta,
abstractmethod
)

from abc import ABCMeta
from abc import abstractmethod
import six

from ...metrics import formatting


INSTRUMENT_FILE_PREFIX = "__instrument"


@six.add_metaclass(ABCMeta)
class InstrumentPlugin( object ):
"""Describes how to instrument job scripts and retrieve collected metrics."""
__metaclass__ = ABCMeta
formatter = formatting.JobMetricFormatter()

@property
Expand Down
7 changes: 5 additions & 2 deletions lib/galaxy/jobs/runners/util/cli/__init__.py
@@ -1,8 +1,11 @@
"""
"""
from glob import glob
from os.path import basename, join
from os import getcwd
from os.path import (
basename,
join
)

DEFAULT_SHELL_PLUGIN = 'LocalShell'

Expand Down Expand Up @@ -61,7 +64,7 @@ def get_job_interface(self, job_params):
raise ValueError(ERROR_MESSAGE_NO_JOB_PLUGIN)
job_plugin_class = self.cli_job_interfaces.get(job_plugin, None)
if not job_plugin_class:
raise ValueError(ERROR_MESSAGE_NO_SUCH_JOB_PLUGIN % (job_plugin, self.cli_job_interfaces.keys()))
raise ValueError(ERROR_MESSAGE_NO_SUCH_JOB_PLUGIN % (job_plugin, list(self.cli_job_interfaces.keys())))
job_interface = job_plugin_class(**job_params)

return job_interface
Expand Down
9 changes: 7 additions & 2 deletions lib/galaxy/jobs/runners/util/cli/job/__init__.py
@@ -1,11 +1,16 @@
"""
Abstract base class for cli job plugins.
"""
from abc import ABCMeta, abstractmethod
from abc import (
ABCMeta,
abstractmethod
)

import six


@six.add_metaclass(ABCMeta)
class BaseJobExec(object):
__metaclass__ = ABCMeta

@abstractmethod
def __init__(self, **params):
Expand Down
3 changes: 1 addition & 2 deletions lib/galaxy/jobs/runners/util/cli/job/slurm.py
@@ -1,10 +1,9 @@
# A simple CLI runner for slurm that can be used when running Galaxy from a
# non-submit host and using a Slurm cluster.
from logging import getLogger

from ..job import BaseJobExec

from logging import getLogger

try:
from galaxy.model import Job
job_states = Job.states
Expand Down
9 changes: 7 additions & 2 deletions lib/galaxy/jobs/runners/util/cli/shell/__init__.py
@@ -1,11 +1,16 @@
"""
Abstract base class for runners which execute commands via a shell.
"""
from abc import ABCMeta, abstractmethod
from abc import (
ABCMeta,
abstractmethod
)

import six


@six.add_metaclass(ABCMeta)
class BaseShellExec(object):
__metaclass__ = ABCMeta

@abstractmethod
def __init__(self, *args, **kwargs):
Expand Down
12 changes: 9 additions & 3 deletions lib/galaxy/jobs/runners/util/cli/shell/local.py
@@ -1,11 +1,17 @@
from logging import getLogger
from subprocess import (
PIPE,
Popen
)
from tempfile import TemporaryFile
from time import sleep
from subprocess import Popen, PIPE

from ..shell import BaseShellExec
from ....util import Bunch, kill_pid
from ....util import (
Bunch,
kill_pid
)

from logging import getLogger
log = getLogger(__name__)

TIMEOUT_ERROR_MESSAGE = u'Execution timed out'
Expand Down
3 changes: 2 additions & 1 deletion lib/galaxy/jobs/runners/util/cli/shell/rsh.py
@@ -1,6 +1,7 @@
from logging import getLogger

from .local import LocalShell

from logging import getLogger
log = getLogger(__name__)

__all__ = ('RemoteShell', 'SecureShell', 'GlobusSecureShell')
Expand Down
9 changes: 8 additions & 1 deletion lib/galaxy/jobs/runners/util/condor/__init__.py
@@ -1,7 +1,14 @@
"""
Condor helper utilities.
"""
from subprocess import Popen, PIPE, STDOUT, check_call, CalledProcessError
from subprocess import (
CalledProcessError,
check_call,
PIPE,
Popen,
STDOUT
)

from ..external import parse_external_id

DEFAULT_QUERY_CLASSAD = dict(
Expand Down
4 changes: 2 additions & 2 deletions lib/galaxy/jobs/runners/util/kill.py
@@ -1,10 +1,10 @@
import os
from platform import system
from time import sleep
from subprocess import Popen
from time import sleep

try:
from psutil import Process, NoSuchProcess
from psutil import NoSuchProcess, Process
except ImportError:
""" Don't make psutil a strict requirement, but use if available. """
Process = None
Expand Down
2 changes: 1 addition & 1 deletion lib/galaxy/jobs/runners/util/retry.py
@@ -1,7 +1,7 @@
import logging
from itertools import count
from time import sleep

import logging
log = logging.getLogger(__name__)

DEFAULT_MAX_RETRIES = -1 # By default don't retry.
Expand Down
6 changes: 4 additions & 2 deletions lib/galaxy/jobs/runners/util/sudo.py
@@ -1,6 +1,8 @@
import logging

from subprocess import Popen, PIPE
from subprocess import (
PIPE,
Popen
)

SUDO_PATH = '/usr/bin/sudo'
SUDO_PRESERVE_ENVIRONMENT_ARG = '-E'
Expand Down
5 changes: 3 additions & 2 deletions lib/galaxy/tools/deps/container_resolvers/__init__.py
Expand Up @@ -5,17 +5,18 @@
abstractproperty,
)

import six

from galaxy.util.dictifiable import Dictifiable


@six.add_metaclass(ABCMeta)
class ContainerResolver(Dictifiable, object):
"""Description of a technique for resolving container images for tool execution."""

# Keys for dictification.
dict_collection_visible_keys = ['resolver_type']

__metaclass__ = ABCMeta

def __init__(self, app_info=None, **kwds):
"""Default initializer for ``ContainerResolver`` subclasses."""
self.app_info = app_info
Expand Down
5 changes: 3 additions & 2 deletions lib/galaxy/tools/deps/containers.py
Expand Up @@ -279,8 +279,8 @@ def __init__(self, working_directory, tool_directory, job_directory, job_directo
self.job_directory_type = job_directory_type # "galaxy" or "pulsar"


@six.add_metaclass(ABCMeta)
class Container( object ):
__metaclass__ = ABCMeta

def __init__(self, container_id, app_info, tool_info, destination_info, job_info, container_description):
self.container_id = container_id
Expand Down Expand Up @@ -445,8 +445,9 @@ class NullContainer(object):
def __init__(self):
pass

def __nonzero__(self):
def __bool__(self):
return False
__nonzero__ = __bool__


NULL_CONTAINER = NullContainer()
6 changes: 3 additions & 3 deletions lib/galaxy/tools/deps/installable.py
Expand Up @@ -2,13 +2,14 @@

import logging
import os

from abc import (
ABCMeta,
abstractmethod,
abstractproperty,
)

import six

from galaxy.util.filelock import (
FileLock,
FileLockException
Expand All @@ -17,11 +18,10 @@
log = logging.getLogger(__name__)


@six.add_metaclass(ABCMeta)
class InstallableContext(object):
"""Represent a directory/configuration of something that can be installed."""

__metaclass__ = ABCMeta

@abstractmethod
def is_installed(self):
"""Return bool indicating if the configured software is installed."""
Expand Down