1 new commit in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/commits/db70af871fd0/ Changeset: db70af871fd0 User: natefoo Date: 2015-02-12 20:35:19+00:00 Summary: Pass the egg env variables onto jobs. Affected #: 2 files diff -r d540227165d54950208d3948e2bdecd4babc70ca -r db70af871fd0f32b67109dcf9a5a8f2ef5846e55 lib/galaxy/eggs/__init__.py --- a/lib/galaxy/eggs/__init__.py +++ b/lib/galaxy/eggs/__init__.py @@ -61,15 +61,13 @@ self.distribution = None self.dir = None self.removed_location = None - self.enable_fetch = crate.galaxy_config.enable_egg_fetch + self.enable_fetch = crate.enable_egg_fetch if self.name is not None and self.version is not None: self.set_distribution() def set_dir( self ): global eggs_dir self.dir = eggs_dir - if not os.path.exists( self.dir ): - os.makedirs( self.dir ) def set_distribution( self ): """ @@ -131,6 +129,8 @@ def _fetch(): if self.url is None: return False + if not os.path.exists( self.dir ): + os.makedirs( self.dir ) alternative = None try: url = self.url + '/' + self.distribution.egg_name() + '.egg' @@ -284,7 +284,7 @@ """ config_file = os.path.join( galaxy_dir, 'eggs.ini' ) - def __init__( self, galaxy_config_file, platform=None ): + def __init__( self, galaxy_config_file=None, platform=None ): self.eggs = {} self.config = CaseSensitiveConfigParser() self.repo = None @@ -293,6 +293,9 @@ self.py_platform = None if platform is not None: self.py_platform = platform.split( '-' )[0] + self.enable_egg_fetch = string_as_bool(os.environ.get('GALAXY_CONFIG_ENABLE_EGG_FETCH', True)) + self.enable_eggs = string_as_bool(os.environ.get('GALAXY_CONFIG_ENABLE_EGGS', True)) + self.try_dependencies_from_env = string_as_bool(os.environ.get('GALAXY_CONFIG_TRY_DEPENDENCIES_FROM_ENV', False)) self.galaxy_config = GalaxyConfig( galaxy_config_file ) self.parse() @@ -381,7 +384,7 @@ """ Try to resolve (e.g. fetch) all eggs in the crate. """ - if self.galaxy_config.enable_eggs and not self.galaxy_config.try_dependencies_from_env: + if self.enable_eggs and not self.try_dependencies_from_env: if all: eggs = self.all_eggs else: @@ -403,19 +406,12 @@ always_conditional = ( 'pysam', 'ctypes', 'python_daemon' ) def __init__( self, config_file ): - self.enable_egg_fetch = True - self.enable_eggs = True - self.try_dependencies_from_env = False if config_file is None: self.config = None else: self.config = ConfigParser.ConfigParser() if self.config.read( config_file ) == []: raise Exception( "error: unable to read Galaxy config from %s" % config_file ) - for opt in ('enable_egg_fetch', 'enable_eggs', 'try_dependencies_from_env'): - var = 'GALAXY_CONFIG_' + opt.upper() - if var in os.environ: - setattr(self, opt, string_as_bool(os.environ[var])) def check_conditional( self, egg_name ): def check_pysam(): @@ -470,11 +466,11 @@ def require( req_str ): c = Crate( None ) req = pkg_resources.Requirement.parse( req_str ) - if c.galaxy_config.try_dependencies_from_env or not c.galaxy_config.enable_eggs: + if c.try_dependencies_from_env or not c.enable_eggs: try: return pkg_resources.working_set.require( req_str ) except Exception as exc: - if not c.galaxy_config.enable_eggs: + if not c.enable_eggs: raise log.info("%s not found in local environment, will try Galaxy egg: %s", (req_str, exc)) # TODO: This breaks egg version requirements. Not currently a problem, but diff -r d540227165d54950208d3948e2bdecd4babc70ca -r db70af871fd0f32b67109dcf9a5a8f2ef5846e55 lib/galaxy/jobs/runners/__init__.py --- a/lib/galaxy/jobs/runners/__init__.py +++ b/lib/galaxy/jobs/runners/__init__.py @@ -12,6 +12,7 @@ from Queue import Queue, Empty +import galaxy.eggs import galaxy.jobs from galaxy.jobs.command_factory import build_command from galaxy import model @@ -269,12 +270,20 @@ external_metadata_proc.wait() log.debug( 'execution of external set_meta for job %d finished' % job_wrapper.job_id ) + def _get_egg_env_opts(self): + env = [] + crate = galaxy.eggs.Crate() + for opt in ('enable_egg_fetch', 'enable_eggs', 'try_dependencies_from_env'): + env.append('GALAXY_CONFIG_%s="%s"; export GALAXY_CONFIG_%s' % (opt.upper(), getattr(crate, opt), opt.upper())) + return env + def get_job_file(self, job_wrapper, **kwds): job_metrics = job_wrapper.app.job_metrics job_instrumenter = job_metrics.job_instrumenters[ job_wrapper.job_destination.id ] env_setup_commands = kwds.get( 'env_setup_commands', [] ) env_setup_commands.append( job_wrapper.get_env_setup_clause() or '' ) + env_setup_commands.extend( self._get_egg_env_opts() or [] ) destination = job_wrapper.job_destination or {} envs = destination.get( "env", [] ) for env in envs: Repository URL: https://bitbucket.org/galaxy/galaxy-central/ -- This is a commit notification from bitbucket.org. You are receiving this because you have the service enabled, addressing the recipient of this email.