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

yaml conf: make 'export yaml config' a user invokable feature #1285

Merged
Merged
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions docs/source/dev/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ Developer documentation
sample-changer-changes-and-maintenance.md
tutorial.md
deployment.md
yaml_conf_migration.md
15 changes: 15 additions & 0 deletions docs/source/dev/yaml_conf_migration.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# YAML configuration migration

Historically MXCuBE used XML files for configuring hardware objects.
Now it's possible to use YAML files instead of XML files.
To help with migration to YAML files, MXCuBE-Web can export loaded hardware objects configurations as YAML files.

Use `--export-yaml-config` argument when starting MXCuBE-web to enable YAML export.
For example, if you use:

```
$ mxcubeweb-server --export-yaml-config <my-yaml-dir>
```

`mxcubeweb-server` will load your hardware object configuration as normal.
Then it will write the loaded configuration into the `<my-yaml-dir>`.
12 changes: 11 additions & 1 deletion mxcubeweb/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import redis # noqa: E402
import sys # noqa: E402
import traceback # noqa: E402
from pathlib import Path # noqa: E402

from mxcubeweb.server import Server as server # noqa: E402
from mxcubeweb.app import MXCUBEApplication as mxcube # noqa: E402
Expand Down Expand Up @@ -99,6 +100,13 @@ def parse_args(argv):
default=False,
)

opt_parser.add_argument(
"--export-yaml-config",
dest="yaml_export_directory",
type=Path,
help="write YAML configuration to specified path",
)

# If `argv` is `None`, then `argparse.ArgumentParser.parse_args`
# will know to read from `sys.argv` instead.
return opt_parser.parse_args(argv)
Expand All @@ -119,7 +127,9 @@ def build_server_and_config(test=False, argv=None):
# as the hwr_directory. I need it for sensible managing of a multi-beamline test set-up
# without continuously editing the main config files.
# Note that the machinery was all there in the core already. rhfogh.
HWR.init_hardware_repository(cmdline_options.hwr_directory)
HWR.init_hardware_repository(
cmdline_options.hwr_directory, cmdline_options.yaml_export_directory
)
config_path = HWR.get_hardware_repository().find_in_repository("mxcube-web")

cfg = Config(config_path)
Expand Down
Loading