Skip to content

Commit

Permalink
Fix object stores' __init__() methods doc
Browse files Browse the repository at this point in the history
Also:
- remove unused parameters when calling the parent constructors
- Python3 compatibility
  • Loading branch information
nsoranzo committed Nov 2, 2016
1 parent 0c28a64 commit 1c68e0a
Showing 1 changed file with 42 additions and 38 deletions.
80 changes: 42 additions & 38 deletions lib/galaxy/objectstore/__init__.py
Expand Up @@ -80,15 +80,16 @@ class ObjectStore(object):

def __init__(self, config, **kwargs):
"""
Create a new ObjectStore.
:type config: object
:param config: An object, most likely populated from
`galaxy/config.ini`, having the following attributes:
config -- Python object with any number of attributes. Most likely
populated from `galaxy/config.ini`. The following attributes are
currently used:
object_store_check_old_style (only used by the DiskObjectStore)
jobs_directory -- Each job is given a unique empty directory
as its current working directory. This option defines in what
parent directory those directories will be created.
* object_store_check_old_style (only used by the
:class:`DiskObjectStore` subclass)
* jobs_directory -- Each job is given a unique empty directory
as its current working directory. This option defines in what
parent directory those directories will be created.
* new_file_path -- Used to set the 'temp' extra_dir.
"""
self.running = True
self.extra_dirs = {}
Expand Down Expand Up @@ -222,24 +223,24 @@ class DiskObjectStore(ObjectStore):
"""

def __init__(self, config, config_xml=None, file_path=None, extra_dirs=None):
"""The constructor.
config -- Python object with any number of attributes. Most likely
populated from `galaxy/config.ini`. The DiskObjectStore specific
attributes are:
object_store_check_old_style
job_directory -- Each job is given a unique empty
directory as its current working directory. This option
defines in what parent directory those directories will be
created.
new_file_path -- Used to set the 'temp' extra_dir.
file_path -- Default directory to store objects to disk in.
umask -- the permission bits for newly `create()`d files.
config_xml -- An ElementTree object.
file_path -- Override for the config.file_path value.
extra_dirs -- Dictionary: keys are string, values are directory paths.
"""
super(DiskObjectStore, self).__init__(config, config_xml=None, file_path=file_path, extra_dirs=extra_dirs)
"""
:type config: object
:param config: An object, most likely populated from
`galaxy/config.ini`, having the same attributes needed by
:class:`ObjectStore` plus:
* file_path -- Default directory to store objects to disk in.
* umask -- the permission bits for newly created files.
:type config_xml: ElementTree
:type file_path: str
:param file_path: Override for the `config.file_path` value.
:type extra_dirs: dict
:param extra_dirs: Keys are string, values are directory paths.
"""
super(DiskObjectStore, self).__init__(config)
self.file_path = file_path or config.file_path
# The new config_xml overrides universe settings.
if config_xml is not None:
Expand Down Expand Up @@ -452,7 +453,7 @@ class NestedObjectStore(ObjectStore):

def __init__(self, config, config_xml=None):
"""Extend `ObjectStore`'s constructor."""
super(NestedObjectStore, self).__init__(config, config_xml=config_xml)
super(NestedObjectStore, self).__init__(config)
self.backends = {}

def shutdown(self):
Expand All @@ -471,7 +472,7 @@ def file_ready(self, obj, **kwargs):

def create(self, obj, **kwargs):
"""Create a backing file in a random backend."""
random.choice(self.backends.values()).create(obj, **kwargs)
random.choice(list(self.backends.values())).create(obj, **kwargs)

def empty(self, obj, **kwargs):
"""For the first backend that has this `obj`, determine if it is empty."""
Expand Down Expand Up @@ -529,14 +530,17 @@ class DistributedObjectStore(NestedObjectStore):

def __init__(self, config, config_xml=None, fsmon=False):
"""
Create a new DistributedObjectStore.
:type config: object
:param config: An object, most likely populated from
`galaxy/config.ini`, having the same attributes needed by
:class:`NestedObjectStore` plus:
* distributed_object_store_config_file
:type config_xml: ElementTree
config -- Python object with any number of attributes. Most likely
populated from `galaxy/config.ini`. The DistributedObjectStore
specific attributes are:
distributed_object_store_config_file
config_xml -- An ElementTree object
fsmon -- boolean. If true, monitor the file system for free space,
:type fsmon: bool
:param fsmon: If True, monitor the file system for free space,
removing backends when they get too full.
"""
super(DistributedObjectStore, self).__init__(config,
Expand All @@ -555,7 +559,7 @@ def __init__(self, config, config_xml=None, fsmon=False):
random.seed()
self.__parse_distributed_config(config, config_xml)
self.sleeper = None
if fsmon and ( self.global_max_percent_full or filter( lambda x: x != 0.0, self.max_percent_full.values() ) ):
if fsmon and ( self.global_max_percent_full or [_ for _ in self.max_percent_full.values() if _ != 0.0] ):
self.sleeper = Sleeper()
self.filesystem_monitor_thread = threading.Thread(target=self.__filesystem_monitor)
self.filesystem_monitor_thread.setDaemon( True )
Expand Down Expand Up @@ -610,7 +614,7 @@ def __filesystem_monitor(self):
maxpct = self.max_percent_full[id] or self.global_max_percent_full
pct = backend.get_store_usage_percent()
if pct > maxpct:
new_weighted_backend_ids = filter(lambda x: x != id, new_weighted_backend_ids)
new_weighted_backend_ids = [_ for _ in new_weighted_backend_ids if _ != id]
self.weighted_backend_ids = new_weighted_backend_ids
self.sleeper.sleep(120) # Test free space every 2 minutes

Expand Down Expand Up @@ -741,7 +745,7 @@ def build_object_store_from_config(config, fsmon=False, config_xml=None):


def local_extra_dirs( func ):
"""Non-local plugin decorator using local directories for the extra_dirs (job_working_directory and temp)."""
"""Non-local plugin decorator using local directories for the extra_dirs (job_work and temp)."""
def wraps( self, *args, **kwargs ):
if kwargs.get( 'base_dir', None ) is None:
return func( self, *args, **kwargs )
Expand Down

0 comments on commit 1c68e0a

Please sign in to comment.