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

Run installed Galaxy with no config and a simplified entry point #19050

Merged
merged 12 commits into from
Oct 29, 2024
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion doc/source/admin/galaxy_options.rst
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,8 @@
:Description:
Set to true to instruct Galaxy to install Conda from the web
automatically if it cannot find a local copy and conda_exec is not
configured.
configured. The default is true if running Galaxy from source, and
false if running from installed packages.
:Default: ``true``
:Type: bool

Expand Down
3 changes: 3 additions & 0 deletions lib/galaxy/config/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -982,6 +982,9 @@ def _process_config(self, kwargs: Dict[str, Any]) -> None:
# self, populate config_dict
self.config_dict["conda_mapping_files"] = [self.local_conda_mapping_file, _default_mapping]

if not running_from_source and kwargs.get("conda_auto_init") is None:
self.config_dict["conda_auto_init"] = False
natefoo marked this conversation as resolved.
Show resolved Hide resolved

if self.container_resolvers_config_file:
self.container_resolvers_config_file = self._in_config_dir(self.container_resolvers_config_file)

Expand Down
3 changes: 2 additions & 1 deletion lib/galaxy/config/sample/galaxy.yml.sample
Original file line number Diff line number Diff line change
Expand Up @@ -589,7 +589,8 @@ galaxy:

# Set to true to instruct Galaxy to install Conda from the web
# automatically if it cannot find a local copy and conda_exec is not
# configured.
# configured. The default is true if running Galaxy from source, and
# false if running from installed packages.
#conda_auto_init: true

# You must set this to true if conda_prefix and job_working_directory
Expand Down
3 changes: 2 additions & 1 deletion lib/galaxy/config/schemas/config_schema.yml
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,8 @@ mapping:
required: false
nsoranzo marked this conversation as resolved.
Show resolved Hide resolved
desc: |
Set to true to instruct Galaxy to install Conda from the web automatically
if it cannot find a local copy and conda_exec is not configured.
if it cannot find a local copy and conda_exec is not configured. The default is
true if running Galaxy from source, and false if running from installed packages.

conda_copy_dependencies:
type: bool
Expand Down
5 changes: 5 additions & 0 deletions lib/galaxy/model/orm/scripts.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
DEFAULT_CONFIG_NAMES = ["galaxy", "universe_wsgi"]
DEFAULT_CONFIG_PREFIX = ""
DEFAULT_DATABASE = "galaxy"
ALEMBIC_CONFIG = os.path.abspath(os.path.join(os.path.dirname(__file__), os.pardir, "migrations", "alembic.ini"))


DATABASE = {
"galaxy": {
Expand Down Expand Up @@ -163,6 +165,9 @@ def _insert_x_argument(key, value):
_insert_x_argument("tsi_url", tsi_config.url)
_insert_x_argument("gxy_url", gxy_config.url)

sys.argv.insert(1, "--config")
sys.argv.insert(2, ALEMBIC_CONFIG)

if "heads" in sys.argv and "upgrade" in sys.argv:
i = sys.argv.index("heads")
sys.argv[i] = f"{GXY}@head"
Expand Down
4 changes: 3 additions & 1 deletion lib/galaxy/util/properties.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def load_app_properties(
config_section = config_section or ini_section

# read from file or init w/no file
if config_file:
if config_file and os.path.exists(config_file):
properties = read_properties_from_file(config_file, config_section)
else:
properties = {"__file__": None}
Expand Down Expand Up @@ -208,6 +208,8 @@ def get_data_dir(properties):
if data_dir is None:
if running_from_source:
data_dir = "./database"
elif properties["__file__"] is None:
data_dir = "./data"
else:
config_dir = properties.get("config_dir", os.path.dirname(properties["__file__"]))
data_dir = os.path.join(config_dir, "data")
Expand Down
5 changes: 1 addition & 4 deletions lib/galaxy/web/framework/middleware/static.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,7 @@ def __init__(self, directory, cache_seconds=None, directory_per_host=None):

def __call__(self, environ, start_response):
path_info = environ.get("PATH_INFO", "")
script_name = environ.get("SCRIPT_NAME", "")
if script_name == "/robots.txt" or script_name == "/favicon.ico":
filename = script_name.replace("/", "")
elif not path_info:
if not path_info:
# See if this is a static file hackishly mapped.
if os.path.exists(self.directory) and os.path.isfile(self.directory):
app = FileApp(self.directory)
Expand Down
31 changes: 23 additions & 8 deletions lib/galaxy/webapps/base/webapp.py
Original file line number Diff line number Diff line change
Expand Up @@ -1156,19 +1156,34 @@ def build_url_map(app, global_conf, **local_conf):
# Send to dynamic app by default
urlmap["/"] = app

def get_static_from_config(option_name, default_path):
config_val = conf.get(option_name, default_url_path(default_path))
def get_static_from_config(option_name, default_path, sample=None):
config_val = conf.get(option_name)
default = default_url_path(default_path)
if not config_val:
if not os.path.exists(default) and sample:
config_val = os.path.abspath(f"{sample}")
else:
config_val = default
per_host_config_option = f"{option_name}_by_host"
per_host_config = conf.get(per_host_config_option)
return Static(config_val, cache_time, directory_per_host=per_host_config)

# Define static mappings from config
urlmap["/static"] = get_static_from_config("static_dir", "static/")
urlmap["/images"] = get_static_from_config("static_images_dir", "static/images")
urlmap["/static/scripts"] = get_static_from_config("static_scripts_dir", "static/scripts/")
urlmap["/static/welcome.html"] = get_static_from_config("static_welcome_html", "static/welcome.html")
urlmap["/favicon.ico"] = get_static_from_config("static_favicon_dir", "static/favicon.ico")
urlmap["/robots.txt"] = get_static_from_config("static_robots_txt", "static/robots.txt")
static_dir = get_static_from_config("static_dir", "static/")
static_dir_bare = static_dir.directory.rstrip("/")
urlmap["/static"] = static_dir
urlmap["/images"] = get_static_from_config("static_images_dir", f"{static_dir_bare}/images")
urlmap["/static/scripts"] = get_static_from_config("static_scripts_dir", f"{static_dir_bare}/scripts/")

urlmap["/static/welcome.html"] = get_static_from_config(
"static_welcome_html", f"{static_dir_bare}/welcome.html", sample=default_url_path("static/welcome.sample.html")
)
urlmap["/favicon.ico"] = get_static_from_config(
"static_favicon_dir", f"{static_dir_bare}/favicon.ico", sample=default_url_path("static/favicon.ico")
)
urlmap["/robots.txt"] = get_static_from_config(
"static_robots_txt", f"{static_dir_bare}/robots.txt", sample=default_url_path("static/robots.txt")
)

if "static_local_dir" in conf:
urlmap["/static_local"] = Static(conf["static_local_dir"], cache_time)
Expand Down
30 changes: 30 additions & 0 deletions lib/galaxy/webapps/galaxy/script.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import os
from argparse import ArgumentParser

import uvicorn


def main() -> None:
parser = ArgumentParser(
prog="galaxy-web",
description="Run Galaxy Web Server",
)
parser.add_argument("--config", "-c", help="Galaxy config file")
parser.add_argument("--single-user", "-s", help="Single user mode as user SINGLE_USER")
parser.add_argument("--bind", "-b", default="localhost:8080", help="Bind to <host>:<port>")
parser.add_argument(
"--client-path", "-n", default="node_modules/@galaxyproject/galaxy-client", help="Path to Galaxy client"
)
args = parser.parse_args()
if args.config:
os.environ["GALAXY_CONFIG_FILE"] = args.config
if args.single_user:
os.environ["GALAXY_CONFIG_SINGLE_USER"] = args.single_user
os.environ["GALAXY_CONFIG_ADMIN_USERS"] = args.single_user
os.environ["GALAXY_CONFIG_STATIC_DIR"] = args.client_path
uvicorn.run(
"galaxy.webapps.galaxy.fast_factory:factory",
factory=True,
host=args.bind.split(":")[0],
port=int(args.bind.split(":")[1]),
)
1 change: 1 addition & 0 deletions packages/app/setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ install_requires =
Mako
Markdown
MarkupSafe
mercurial
packaging
paramiko!=2.9.0,!=2.9.1
pebble
Expand Down
36 changes: 36 additions & 0 deletions packages/package-dev-install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/bin/bash
#
# Install packages in development mode, for running installed Galaxy from the source
#
set -euo pipefail

editable=false

while getopts ':e' OPTION
do
case $OPTION in
e)
editable=true
;;
esac
done
shift $((OPTIND - 1))

up_to="${1:-}"

if [ -n "$up_to" -a ! -d "$up_to" ]; then
echo "ERROR: package does not exist: $up_to"
exit 1
fi

while read package; do
[ -n "$package" ] || continue
pushd $package
if $editable; then
pip install -e .
else
pip install .
fi
popd
[ "$package" != "$up_to" ] || exit
done < packages_by_dep_dag.txt
4 changes: 4 additions & 0 deletions packages/web_apps/setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ install_requires =
packages = find:
python_requires = >=3.8

[options.entry_points]
console_scripts =
galaxy-web = galaxy.webapps.galaxy.script:main

[options.packages.find]
exclude =
tests*
Expand Down
1 change: 0 additions & 1 deletion scripts/common_startup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ done
SAMPLES="
tool-data/shared/ucsc/builds.txt.sample
tool-data/shared/ucsc/manual_builds.txt.sample
static/welcome.html.sample
"

RMFILES="
Expand Down
File renamed without changes.
Loading