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

Alternative JSON configuration system for OMERO.web #6086

Draft
wants to merge 9 commits into
base: develop
Choose a base branch
from

Conversation

manics
Copy link
Member

@manics manics commented Jul 17, 2019

What this PR does

This is an experimental implementation of an alternative config system discussed in #6053 (comment)

The configuration format is described in the doc-string of omero.config.load_json_configs: https://github.com/openmicroscopy/openmicroscopy/compare/develop...manics:web-json-config?expand=1#diff-5deedb87cde10b4e5f8a28d83b49559aR461
This is in OmeroPy not OmeroWeb since we might want to use this elsewhere in future.

To enable the new config system, set the environment variable OMERO_WEB_CONFIG_DIR to the directory containing your *.json config files. Currently these are merged with the existing config.xml properties though this could be easily changed. JSON properties override config.xml ones. .yaml/.yml config files can also be used if PyYAML is installed.

The major change in omeroweb.settings.py is the handling the difference between JSON properties which are a typed scalars or objects, and config.xml which is always a string which is converted by OMERO.web where necessary. This means the conversion functions used by OMERO.web to convert the config.xml string value to the type required by OMERO.web have to be aware of the source.

This should be backwards compatible so existing config.xml properties will be converted as expected, and furthermore external web-apps that use mapping functions should continue to work if their properties are set using config.xml. It is not possible to use the new JSON config system in apps that haven't been updated.

Testing this PR

$ cat webconfig/logging.json
{
    "omero.web.django_additional_settings": [
        [
            "LOGGING",
            {
                "handlers": {
                    "console": {
                        "formatter": "standard",
                        "class": "logging.StreamHandler",
                        "level": "INFO"
                    }
                },
                "loggers": {
                    "": {
                        "level": "DEBUG",
                        "propagate": true,
                        "handlers": [
                            "console"
                        ]
                    }
                },
                "version": 1,
                "disable_existing_loggers": false,
                "formatters": {
                    "standard": {
                        "format": "%(asctime)s %(levelname)5.5s [%(name)40.40s] (proc.%(process)5.5d) %(funcName)s():%(lineno)d %(message)s"
                    }
                }
            }
        ]
    ]
}

$ cat webconfig/tmp-append.json
{
  "_mode": "append",
  "omero.web.middleware": [
    {
      "index": 0,
      "class": "whitenoise.middleware.WhiteNoiseMiddleware"
    }
  ],
  "omero.web.server_list": [
    [
      "idr.openmicroscopy.org",
      4064,
      "idr"
    ],
    [
      "example1.openmicroscopy.org",
      4064,
      "example1"
    ],
    [
      "example2.openmicroscopy.org",
      4064,
      "example2"
    ]
  ]
}

$ cat webconfig/tmp-set.json
{
  "omero.web.api.limit": 100,
  "Xomero.web.api.max_limit": 100,
  "omero.web.debug": false
}
omero config set omero.web.... # If you want to test merging of properties

export OMERO_WEB_CONFIG_DIR=/path/to/webconfig
omero web start --foreground

manics added 9 commits July 5, 2019 17:43
config.xml values are always strings so need to be mapped to the required types, JSON value are already type so only need to be mapped for limited values
This is necessary because the default values have to be loaded separately
New method that can be used to lookup OMERO.web django and config.xml settings
Inspect the web settings mapping function and log a deprecation warning for old functions instead of failing.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
exclude transfer Migrate to another repository
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants