diff --git a/docs/source/conf.py b/docs/source/conf.py index 5a2d244..5441fa5 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -64,3 +64,29 @@ # -- Copybutton configuration ------------------------------------------------- copybutton_exclude = ".linenos, .gp" copybutton_selector = "div:not(.no-copybutton) > div.highlight > pre" + +# -- Version substitution ----------------------------------------------------- +# Replaced in all source and included files, including inside code blocks + +node_version = "v0.1.1" +_SUBSTITUTIONS = {"|node_version|": node_version} + + +def _substitute(content: list[str]) -> None: + """Replace substitution tokens in raw source content (in place).""" + for token, value in _SUBSTITUTIONS.items(): + content[0] = content[0].replace(token, value) + + +def _on_source_read(app, docname, content) -> None: + _substitute(content) + + +def _on_include_read(app, relative_path, parent_docname, content) -> None: + _substitute(content) + + +def setup(app) -> None: + """Register source substitution hooks.""" + app.connect("source-read", _on_source_read) + app.connect("include-read", _on_include_read) diff --git a/docs/source/index.md b/docs/source/index.md index 3016fdb..2b87ea5 100644 --- a/docs/source/index.md +++ b/docs/source/index.md @@ -31,3 +31,13 @@ fl_ready_dataset fedbiomed_node_part_1 fedbiomed_node_part_2 ``` + +```{toctree} +--- +hidden: +includehidden: +titlesonly: +caption: Maintenance +--- +node_update +``` diff --git a/docs/source/initial_setup.md b/docs/source/initial_setup.md index 94a587f..2ba8537 100644 --- a/docs/source/initial_setup.md +++ b/docs/source/initial_setup.md @@ -7,7 +7,7 @@ Clone and enter the [`brainflex-node`](https://github.com/neurodatascience/brainflex-node) repository: ```bash -git clone --branch v0.1.1 https://github.com/neurodatascience/brainflex-node +git clone --branch |node_version| https://github.com/neurodatascience/brainflex-node cd brainflex-node ``` diff --git a/docs/source/node_update.md b/docs/source/node_update.md new file mode 100644 index 0000000..8e1716b --- /dev/null +++ b/docs/source/node_update.md @@ -0,0 +1,86 @@ +# Updating the node + +When a new version of [`brainflex-node`](https://github.com/neurodatascience/brainflex-node) is released, follow these steps to update to the latest version (**|node_version|**). + +```{include} _includes/working_directory.md +``` + +## Update the code + +First, check whether you created a work branch: + +```bash +git branch --show-current +``` + +If this prints `work` (or another branch name you created): + +```bash +git fetch origin tag |node_version| --no-tags +git merge --no-edit |node_version| +``` + +If this prints nothing (you skipped the optional `git switch -c work` step in [Initial setup](initial_setup.md)): + +```bash +git fetch origin tag |node_version| --no-tags +git switch --detach |node_version| +``` + +To confirm the update worked, run: + +```bash +git describe --tags +``` + +If you have no commits of your own, this prints `|node_version|`. +If you merged into a branch that had your own commits, it prints something like `|node_version|-2-gabc1234`, which is also fine. + +### Troubleshooting: uncommitted changes + +If you edited files tracked by Git (e.g. `docker-compose.yml`), the update stops with an error like: + +```{code-block} +:caption: Output +error: Your local changes to the following files would be overwritten by [merge|checkout]: + docker-compose.yml +Please commit your changes or stash them before you [merge|switch branches]. +Aborting +``` + +Nothing has been changed yet: your files and your version are as they were. +Commit your changes so they are kept, then update again. + +If `git branch --show-current` printed `work` (or another branch name): + +```bash +git commit -a -m "My local changes" +git merge --no-edit |node_version| +``` + +If it printed nothing, first create a branch so that your commit is not lost, then update with `git merge` (not `git switch --detach`): + +```bash +git switch -c work +git commit -a -m "My local changes" +git merge --no-edit |node_version| +``` + +## Update Python dependencies + +With your virtual environment (or `conda` environment) activated, run: + +```bash +uv pip install -r requirements.txt # or: pip install -r requirements.txt +``` + +This only installs packages that are new or changed in this version. + +## Restart the Fed-BioMed node + +Only do this if you have already started the node (see [Fed-BioMed node: Part 1](fedbiomed_node_part_1.md)): + +```bash +docker compose down +docker compose up -d +```