Skip to content

Make Galaxy (almost) packageable/installable#921

Merged
jmchilton merged 60 commits intogalaxyproject:devfrom
natefoo:installable
Jul 8, 2019
Merged

Make Galaxy (almost) packageable/installable#921
jmchilton merged 60 commits intogalaxyproject:devfrom
natefoo:installable

Conversation

@natefoo
Copy link
Member

@natefoo natefoo commented Oct 15, 2015

2019 Update

This won't be entirely ready for pip install galaxy but does what's needed to quickly finish it up. The plan is for the galaxy-web-apps package package essentially a full install of Galaxy with its web stack, and the galaxy metapackage will be pinned to stable releases. Because the packagification of Galaxy began just before updating this PR happened, the method originally used here (one big package) is no longer valid, and the metapackage isn't working yet. That will happen in a subsequent PR.

This PR includes some important useful pieces:

  • GalaxyConfiguration.config_dir is dirname(config_file) (or . if there is no config file)
  • GalaxyConfiguration.data_dir is ./data
  • No assumption that cwd is galaxy_root
  • No assumption that configs are in ./config/
  • Sample configs are no longer required
  • Galaxy now finds templates, static, and tools via symlinks in the galaxy lib dir (but these are not packageable yet)
  • Sample configs moved to lib/galaxy/config/sample

The exception to the changes above: if running from cwd = galaxy_root, then config_dir and data_dir are <cwd>/config and <cwd>/database as before.

Updated TODO list for the next PR

  • Finish the metapackage
  • Update galaxy-config for YAML configs
  • Add galaxy-uwsgi or galaxy -m uwsgi
  • Package static/
  • Other directories: external_services/, tool-data/, ...
  • Create a galaxy-set-metadata command to replace the tempfile method currently used
  • Move galaxy-manage-db to galaxy-app after package-ify top-level Python files in lib/galaxy. #8293 I think
  • Fix tool migrations
  • Other things I'm not thinking of

Original PR

Building on #428, this attempts to make Galaxy installable via the standard Pythonic mechanism. To use:

  1. Make a virtualenv and activate it
  2. PYTHONPATH= pip install --upgrade pip wheel
  3. make wheels
  4. PYTHONPATH= pip install -i https://wheels.galaxyproject.org/simple/ 'dist/galaxy-16.7.dev0-py2-none-any.whl[postgresql]'
  5. Create a directory somewhere, copy config/galaxy.ini.sample to it as galaxy.ini
  6. galaxy-paster serve galaxy.ini

Alternatively:

  1. Make a virtualenv and activate it
  2. PYTHONPATH= pip install --upgrade pip
  3. make client
  4. PYTHONPATH= pip install -i https://wheels.galaxyproject.org/simple '.[postgresql]' (add -e for editable/develop mode)
  5. As above

TODO list

  • Figure out what to do with lib/galaxy/datatypes/converters/, lib/galaxy/datatypes/set_meatadata_tool.xml, etc. (just use __file__ rather than assuming cwd is galaxy_root?)
  • Fix galaxy-main
  • Make a galaxy-config to create a Galaxy config directory and relevant contents
  • Add a config_dir option to galaxy.ini
  • Move shed_tool_conf.xml to its own config variable
  • Do not require shed_* configs to exist (they can be created as necessary)
  • Figure out what to do with all the mutable stuff (compiled templates, sqlite db, etc.)
  • Install custom pip not needed
  • Install dependencies
  • Figure out what to do with tools/
  • Distribute templates/ and make it findable by Galaxy
  • Distribute static/ and make it findable by Galaxy
  • Other directories: external_services/, tool-data/, ...
  • Clean up the root directory and move packages to the top level
  • Create a galaxy-set-metadata command to replace the tempfile method currently used
  • Fix tool migrations
  • Other things I'm not thinking of

@mr-c
Copy link
Contributor

mr-c commented Oct 15, 2015

💯 !!

@martenson
Copy link
Member

api tests on Jenkins report

Traceback (most recent call last):
  File "./scripts/manage_db.py", line 11, in <module>
    from migrate.versioning.shell import main
ImportError: No module named migrate.versioning.shell

@martenson
Copy link
Member

this needs to be rebased or dev merged into it before jenkins can test

@natefoo
Copy link
Member Author

natefoo commented Oct 20, 2015

@martenson Waiting for the tests to pass on #428 first.

setup.py Outdated
if GALAXY_PACKAGE == "galaxy-lib":
requirements = []
base_packages = [
'galaxy.datatypes',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Datatypes depends on models so it shouldn't live in galaxy-lib in my opinion.

@jmchilton
Copy link
Member

What made you decide what to put in galaxy-app and what to put into galaxy? I feel like we should just figure out galaxy-lib first - and probably after this effort? After that I'd like to aim toward a design of:

  • galaxy-lib (minimal required dependencies)
  • galaxy-models (depends on sqlalchemy and galaxy-lib)
  • galaxy-app (galaxy-models but no web stuff - someday it would be nice to run a webless galaxy process - e.g. job or workflow handlers using just this)
  • galaxy-web (galaxy-app + controllers)

I would start from the bottom and introduce one or so a year as we refactor around these new distinctions? There are a think both practical and abstract design goals with each of these distinctions that I could go into in depth. None of this feels like something that should be rushed though.

@natefoo
Copy link
Member Author

natefoo commented May 17, 2016

What made you decide what to put in galaxy-app and what to put into galaxy?

"This seems like a web package", "This doesn't". Which is why it's almost certainly wrong.

So for now perhaps we should just have galaxy-lib and galaxy.

@nsoranzo
Copy link
Member

It would be nice to make the final tool migration (xref. #636) before this PR is merged.

@natefoo
Copy link
Member Author

natefoo commented May 19, 2016

Per conversation with @jmchilton we are going to add a config_dir option to galaxy.ini so that we can stop assuming the location of everything is relative to the current working directory. Is there a sensible default for this? I suggest the directory containing galaxy.ini.

@natefoo natefoo force-pushed the installable branch 3 times, most recently from 99faf51 to 88c01d7 Compare June 16, 2016 19:23
natefoo added 10 commits July 7, 2016 13:49
if you install it and then run `galaxy` from the root of a Galaxy clone,
after installing all the dependencies (see the end of
./scripts/common_startup.sh), it should start.
tool-shed packages (see galaxyproject#1396). Lots of path fixing to be done still.
"installed Galaxy" world is not the current working directory.
live in the `galaxy` package. Install deps at install time.
nsoranzo added a commit to nsoranzo/galaxy that referenced this pull request Jul 17, 2019
Fix comparisons of relative and absolute paths like the one described
at galaxyproject#921 (comment)
@nsoranzo nsoranzo mentioned this pull request Jul 17, 2019
return os.path.join(self.sample_config_dir, path)

def _parse_config_file_options(self, defaults, listify_defaults, config_kwargs):
for var, defaults in defaults.items():
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably it's not a bug, but reusing defaults variable name as loop variable is surely confusing.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes!! I noticed it and hated it on first site.. I'll submit a quick PR (didn't want to trigger a code review over such a minor thing - but since you mention this.. so thanks :)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ic4f thanks!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nsoranzo How about defaults >> vals?

for var, vals in defaults.items():
    if config_kwargs.get(var, None) is not None:
        path = config_kwargs.get(var)
        setattr(self, var + '_set', True)
    else:
        for val in vals:
            if os.path.exists(resolve_path(val, self.root)):
                path = val 
                break
        else:
            path = vals[-1]
        setattr(self, var + '_set', False)
    setattr(self, var, resolve_path(path, self.root))

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe values/value to make it a bit more different from var.

setattr(self, var + '_set', False)
setattr(self, var, resolve_path(path, self.root))

for var, defaults in listify_defaults.items():
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here too.

try:
tool_conf_source = get_toolbox_parser(config_filename)
except (OSError, IOError) as exc:
for opt in ('shed_tool_conf', 'migrated_tools_config'):
Copy link
Member

@martenson martenson Aug 27, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fresh on dev this is called twice with config_filename=/Users/marten/devel/git/temp/galaxy/config/migrated_tools_conf.xml but once it has getattr(self.app.config, opt) equal to /Users/marten/devel/git/temp/galaxy/config/shed_tool_conf.xml.

so the _dynamic_tool_confs end up being

[{
'tool_path': '/Users/marten/devel/git/temp/galaxy/database/shed_tools',
 'create': '<?xml version="1.0"?>\n<toolbox tool_path="/Users/marten/devel/git/temp/galaxy/database/shed_tools">\n</toolbox>\n', 
'config_filename': '/Users/marten/devel/git/temp/galaxy/config/migrated_tools_conf.xml', 
'config_elems': []}]

which seems wrong?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you create an issue and assign me?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The issue is here: #8484 and you are assigned to it.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, didn't realize this was the same thing, thanks.

@jdavcs jdavcs added the area/configuration Galaxy's configuration system label Sep 19, 2019
nsoranzo added a commit to nsoranzo/galaxy that referenced this pull request Sep 20, 2019
for config files.

Broken in galaxyproject#921 .

For context, see galaxyproject#8639 (comment)

Includes also elimination of `resolve_path` function as in
galaxyproject#8646
nsoranzo added a commit to nsoranzo/galaxy that referenced this pull request Sep 20, 2019
for config files.

Broken in galaxyproject#921 .

For context, see galaxyproject#8639 (comment)

Includes also elimination of `resolve_path` function as in
galaxyproject#8646
jdavcs added a commit to jdavcs/galaxy that referenced this pull request Oct 28, 2019
jdavcs added a commit to jdavcs/galaxy that referenced this pull request Oct 28, 2019
HadleyKing pushed a commit to biocompute-objects/galaxy that referenced this pull request Oct 30, 2019
Fix comparisons of relative and absolute paths like the one described
at galaxyproject#921 (comment)
jdavcs added a commit to jdavcs/galaxy that referenced this pull request Oct 30, 2019
1. Split method body in two
2. Change assignment of config_dir when running from source
3. Ensure value of config_dir is an absolute path

I think splitting the method imporoves readability: its functionality
can be easily grouped into 2 parts: (1) finding and reading the main
config file (I've removed the comment because it was not quite in place
and, I think, not essential to understanding the code); and (2)
setting paths for core config properties based on part (1).

The change to config_dir addresses previous discussions:
galaxyproject#8894 (comment)
galaxyproject#921 (comment)

I could've changed the line in question:
galaxyproject#921 (comment)
to this:
`if self.config_file is None and `config_dir` is not in config_kwargs:`

However, in my opinion, such an edit would further obfuscate the logic
of assigning that value. The proposed solution, I think, although more
verbose, makes the code more straightforward: it is immediately clear
what values are assigned under what circumstances.

Finally, in the previous version `config_dir` can be a relative path if
`config_file` exists, but `config_dir` is set by the user (to a relative
path). That, I believe, was a bug.
@natefoo natefoo mentioned this pull request Apr 2, 2021
9 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/configuration Galaxy's configuration system kind/enhancement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants