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

[22.01] Create config package, move app-related functionality to app #13461

Merged
merged 27 commits into from
Mar 2, 2022
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
62959ee
Move app-related functions and classes to galaxy.app
mvdbeek Feb 27, 2022
2fab58c
Create config package
mvdbeek Feb 28, 2022
98eb857
Move unit tests that requre TS schema
mvdbeek Mar 1, 2022
e252b73
Fix up tests for non-UTC clocks
mvdbeek Mar 1, 2022
56b4ee8
Fix mocking of GalaxyAppConfiguration
mvdbeek Mar 1, 2022
6b20452
Package version.py
mvdbeek Mar 1, 2022
699e7c3
Drop _override_tempdir patch
mvdbeek Mar 1, 2022
0a20259
Drop local import
mvdbeek Mar 1, 2022
3acb731
Use facts directly
mvdbeek Mar 1, 2022
9ec7e87
Debug unit tests
mvdbeek Mar 1, 2022
a3094f7
Drop _override_tempdir patch
mvdbeek Mar 1, 2022
c08a12f
Drop get_database_url helper
mvdbeek Mar 1, 2022
034f518
Move init_models_from_config to galaxy.model.mapping
mvdbeek Mar 1, 2022
cb24832
Adapt project boilerplate
mvdbeek Mar 1, 2022
13e6f34
Drop responses test requirement from config package
mvdbeek Mar 1, 2022
e3b7fe0
Fix package symlinks
mvdbeek Mar 1, 2022
25c5a47
Use imports from top
mvdbeek Mar 1, 2022
7ddf3ea
Add galaxy-objectstore to app package requirement
mvdbeek Mar 1, 2022
6b08108
Fix History formatting
mvdbeek Mar 1, 2022
3c3e60d
Use black style double quotes
mvdbeek Mar 1, 2022
cfd66f4
Switch license back to AFL
mvdbeek Mar 1, 2022
1828f4a
Move more things to the top
mvdbeek Mar 1, 2022
48e2ebe
List transitive dependencies that are imported directly in config pac…
mvdbeek Mar 1, 2022
4cffa78
Drop pykwalify from app requirements
mvdbeek Mar 1, 2022
022bae0
Add pykwalify to ``app`` package test requirements
mvdbeek Mar 1, 2022
6b32e23
Reformat with black and pyupgrade
nsoranzo Mar 1, 2022
e89b47b
Rename project_galaxy_config.py
mvdbeek Mar 1, 2022
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
259 changes: 253 additions & 6 deletions lib/galaxy/app.py

Large diffs are not rendered by default.

359 changes: 66 additions & 293 deletions lib/galaxy/config/__init__.py

Large diffs are not rendered by default.

32 changes: 0 additions & 32 deletions lib/galaxy/web/formatting.py

This file was deleted.

4 changes: 0 additions & 4 deletions lib/galaxy/web_stack/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -633,10 +633,6 @@ def get_app_kwds(config_section, app_name=None):
return application_stack_class().get_app_kwds(config_section, app_name=app_name)


def get_stack_facts(config=None):
return application_stack_instance(config=config).facts


def _uwsgi_configured_mules():
mules = uwsgi.opt.get('mule', [])
return [mules] if isinstance(mules, str) or mules is True else mules
Expand Down
2 changes: 1 addition & 1 deletion lib/tool_shed/webapp/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@
CommonConfigurationMixin,
get_database_engine_options,
)
from galaxy.config import expand_pretty_datetime_format
from galaxy.config.schema import AppSchema
from galaxy.exceptions import ConfigurationError
from galaxy.util import string_as_bool
from galaxy.version import VERSION, VERSION_MAJOR, VERSION_MINOR
from galaxy.web.formatting import expand_pretty_datetime_format

try:
from importlib.resources import files # type: ignore[attr-defined]
Expand Down
2 changes: 0 additions & 2 deletions packages/app/MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
include *.rst *.txt LICENSE
include galaxy/config/schemas/*.yml
include galaxy/config/sample/*.sample*
include galaxy/jobs/runners/util/job_script/*.sh
include galaxy/tools/*tsv
1 change: 1 addition & 0 deletions packages/app/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
galaxy-auth
galaxy-config
galaxy-data
galaxy-job-execution
galaxy-job-metrics
mvdbeek marked this conversation as resolved.
Show resolved Hide resolved
Expand Down
6 changes: 0 additions & 6 deletions packages/app/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ def get_var(var_name):
'galaxy.actions',
'galaxy.app_unittest_utils',
'galaxy.authnz',
'galaxy.config',
'galaxy.dependencies',
'galaxy.forms',
'galaxy.jobs',
Expand Down Expand Up @@ -95,14 +94,9 @@ def get_var(var_name):
ENTRY_POINTS = '''
[console_scripts]
galaxy-main=galaxy.main:main
galaxy-config=galaxy.config.script:main
'''
PACKAGE_DATA = {
# Be sure to update MANIFEST.in for source dist.
'galaxy': [
'config/schemas/*.yml',
'config/sample/*',
],
'tool_shed': [
'scripts/bootstrap_tool_shed/user_info.xml',
],
Expand Down
11 changes: 11 additions & 0 deletions packages/config/HISTORY.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
.. :changelog:

History
-------

.. to_doc

---------------------
22.1.0.dev0
---------------------
Initial release
mvdbeek marked this conversation as resolved.
Show resolved Hide resolved
1 change: 1 addition & 0 deletions packages/config/LICENSE
3 changes: 3 additions & 0 deletions packages/config/MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
include *.rst *.txt LICENSE
include galaxy/config/schemas/*.yml
include galaxy/config/sample/*.sample*
1 change: 1 addition & 0 deletions packages/config/Makefile
14 changes: 14 additions & 0 deletions packages/config/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@

.. image:: https://badge.fury.io/py/galaxy-config.svg
:target: https://pypi.org/project/galaxy-config/


Overview
--------

The Galaxy_ config module.

* Free software: Academic Free License version 3.0
* Code: https://github.com/galaxyproject/galaxy

.. _Galaxy: http://galaxyproject.org/
1 change: 1 addition & 0 deletions packages/config/dev-requirements.txt
1 change: 1 addition & 0 deletions packages/config/galaxy/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__path__ = __import__('pkgutil').extend_path(__path__, __name__) # type: ignore[has-type]
mvdbeek marked this conversation as resolved.
Show resolved Hide resolved
File renamed without changes.
11 changes: 11 additions & 0 deletions packages/config/galaxy/project_galaxy_util.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
__version__ = "22.1.0rc1"
nsoranzo marked this conversation as resolved.
Show resolved Hide resolved

PROJECT_NAME = "galaxy-config"
PROJECT_OWNER = PROJECT_USERAME = "galaxyproject"
PROJECT_URL = "https://github.com/galaxyproject/galaxy"
PROJECT_AUTHOR = 'Galaxy Project and Community'
PROJECT_DESCRIPTION = 'Galaxy Generic Utilities'
PROJECT_EMAIL = 'galaxy-committers@lists.galaxyproject.org'
RAW_CONTENT_URL = "https://raw.github.com/{}/{}/master/".format(
PROJECT_USERAME, PROJECT_NAME
)
mvdbeek marked this conversation as resolved.
Show resolved Hide resolved
2 changes: 2 additions & 0 deletions packages/config/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
galaxy-containers
pykwalify
mvdbeek marked this conversation as resolved.
Show resolved Hide resolved
1 change: 1 addition & 0 deletions packages/config/scripts
1 change: 1 addition & 0 deletions packages/config/setup.cfg
99 changes: 99 additions & 0 deletions packages/config/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
#!/usr/bin/env python

import ast
import os
import re
try:
from setuptools import setup
except ImportError:
from distutils.core import setup

SOURCE_DIR = "galaxy"

_version_re = re.compile(r'__version__\s+=\s+(.*)')

with open('%s/project_galaxy_util.py' % SOURCE_DIR, 'rb') as f:
init_contents = f.read().decode('utf-8')

def get_var(var_name):
pattern = re.compile(r'%s\s+=\s+(.*)' % var_name)
match = pattern.search(init_contents).group(1)
return str(ast.literal_eval(match))

version = get_var("__version__")
PROJECT_NAME = get_var("PROJECT_NAME")
PROJECT_URL = get_var("PROJECT_URL")
PROJECT_AUTHOR = get_var("PROJECT_AUTHOR")
PROJECT_EMAIL = get_var("PROJECT_EMAIL")
PROJECT_DESCRIPTION = get_var("PROJECT_DESCRIPTION")

TEST_DIR = 'tests'
PACKAGES = [
'galaxy',
'galaxy.config',
]
ENTRY_POINTS = '''
[console_scripts]
galaxy-config=galaxy.config.script:main
'''
PACKAGE_DATA = {
# Be sure to update MANIFEST.in for source dist.
'galaxy': [
'config/schemas/*.yml',
'config/sample/*',
],
}
PACKAGE_DIR = {
SOURCE_DIR: SOURCE_DIR,
}

readme = open('README.rst').read()
history = open('HISTORY.rst').read().replace('.. :changelog:', '')

if os.path.exists("requirements.txt"):
requirements = open("requirements.txt").read().split("\n")
else:
# In tox, it will cover them anyway.
requirements = []


test_requirements = open("test-requirements.txt").read().split("\n")


setup(
name=PROJECT_NAME,
version=version,
description=PROJECT_DESCRIPTION,
long_description=readme + '\n\n' + history,
long_description_content_type='text/x-rst',
author=PROJECT_AUTHOR,
author_email=PROJECT_EMAIL,
url=PROJECT_URL,
packages=PACKAGES,
entry_points=ENTRY_POINTS,
package_data=PACKAGE_DATA,
package_dir=PACKAGE_DIR,
include_package_data=True,
install_requires=requirements,
license="MIT",
zip_safe=False,
keywords='galaxy',
classifiers=[
'Development Status :: 5 - Production/Stable',
'Intended Audience :: Developers',
'Environment :: Console',
'License :: OSI Approved :: MIT License',
'Operating System :: POSIX',
'Topic :: Software Development',
'Topic :: Software Development :: Code Generators',
'Topic :: Software Development :: Testing',
'Natural Language :: English',
"Programming Language :: Python :: 3",
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10',
],
test_suite=TEST_DIR,
tests_require=test_requirements
)
1 change: 1 addition & 0 deletions packages/config/test-data
2 changes: 2 additions & 0 deletions packages/config/test-requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
pytest<6.1
responses
mvdbeek marked this conversation as resolved.
Show resolved Hide resolved
1 change: 1 addition & 0 deletions packages/config/tests/config
1 change: 1 addition & 0 deletions packages/config/tests/util
1 change: 1 addition & 0 deletions packages/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ PACKAGE_DIRS=(
objectstore
job_metrics
containers
config
files
tool_util
data
Expand Down
1 change: 1 addition & 0 deletions packages/util/galaxy/version.py
20 changes: 5 additions & 15 deletions test/unit/config/test_config_dataset_storage.py
Original file line number Diff line number Diff line change
@@ -1,34 +1,24 @@
import os.path

import pytest

from galaxy import config
from galaxy.config import BaseAppConfiguration


@pytest.fixture
def mock_config_file(monkeypatch):
# Patch this; otherwise tempfile.tempdir will be set, which is a global variable that
# defines the value of the default `dir` argument to the functions in Python's
# tempfile module - which breaks multiple tests.
monkeypatch.setattr(config.GalaxyAppConfiguration, '_override_tempdir', lambda a, b: None)


def test_object_store_store_by_set(mock_config_file, monkeypatch):
def test_object_store_store_by_set():
# object_store_store_by set by admin
appconfig = config.GalaxyAppConfiguration(object_store_store_by='id')
assert appconfig.object_store_store_by == 'id'


def test_uuid_1(mock_config_file, monkeypatch):
def test_uuid_1():
# object_store_store_by not set
# file_path set by admin to `objects` (no need for the dir to exist)
appconfig = config.GalaxyAppConfiguration(file_path='objects')

assert appconfig.object_store_store_by == 'uuid'


def test_uuid_2(mock_config_file, monkeypatch):
def test_uuid_2(monkeypatch):
# object_store_store_by not set
# file_path not set, `files` dir doesn't exist
monkeypatch.setattr(BaseAppConfiguration, '_path_exists', lambda self, path: False)
Expand All @@ -37,15 +27,15 @@ def test_uuid_2(mock_config_file, monkeypatch):
assert appconfig.object_store_store_by == 'uuid'


def test_id_1(mock_config_file, monkeypatch):
def test_id_1():
# object_store_store_by not set
# file_path set by admin to `not_objects` (no need for the dir to exist)
appconfig = config.GalaxyAppConfiguration(file_path='not_objects')

assert appconfig.object_store_store_by == 'id'


def test_id_2(mock_config_file, monkeypatch):
def test_id_2(monkeypatch):
# object_store_store_by not set
# file_path not set, `files` dir exists
monkeypatch.setattr(BaseAppConfiguration, '_path_exists', lambda self, path: True if os.path.basename(path) == 'files' else False)
Expand Down
Loading