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

SARC 114 - Doc sphinx #72

Merged
merged 23 commits into from
Aug 28, 2023
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
26 changes: 24 additions & 2 deletions .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ jobs:
matrix:
python-version: ['3.10']
toxenv: [black, isort, lint]


steps:
- uses: actions/checkout@v3
Expand All @@ -67,4 +67,26 @@ jobs:

- name: Tests with tox
run: poetry run tox -e ${{ matrix.toxenv }}


test-generate-docs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.10']

steps:
- uses: actions/checkout@v3

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install poetry
poetry install

- name: Tests doc generation
run: poetry run sphinx-build -b html docs/ docs/_build
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ clockwork_ldap.key
.tox/
sarc-cache/
.idea
_build
32 changes: 32 additions & 0 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# .readthedocs.yaml
# Read the Docs configuration file
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details

# Required
version: 2

# Set the OS, Python version and other tools you might need
build:
os: ubuntu-22.04
tools:
python: "3.11"
# You can also specify other tool versions:
# nodejs: "19"
# rust: "1.64"
# golang: "1.19"

# Build documentation in the "docs/" directory with Sphinx
sphinx:
configuration: docs/conf.py

# Optionally build your docs in additional formats such as PDF and ePub
# formats:
# - pdf
# - epub

# Optional but recommended, declare the Python requirements required
# to build your documentation
# See https://docs.readthedocs.io/en/stable/guides/reproducible-builds.html
python:
install:
- requirements: docs/requirements.txt
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,3 +79,12 @@ sarc/account_matching/update_account_matches_in_database.py
sarc/inode_storage_scanner/get_diskusage.py (stub)
```

### How to generate doc

To generate documentation in HTML format in folder `docs\_build`:

```
sphinx-build -b html docs/ docs/_build
```

You can then open `docs\_build\index.html` on a web browser.
20 changes: 20 additions & 0 deletions docs/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Minimal makefile for Sphinx documentation
#

# You can set these variables from the command line, and also
# from the environment for the first two.
SPHINXOPTS ?=
SPHINXBUILD ?= sphinx-build
SOURCEDIR = .
BUILDDIR = _build

# Put it first so that "make" without argument is like "make help".
help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

.PHONY: help Makefile

# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
1 change: 0 additions & 1 deletion docs/account_matching.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

# Quick guide on LDAP retrieval and account matching

## Structure in MongoDB
Expand Down
28 changes: 13 additions & 15 deletions docs/account_matching_manual_procedure.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# Account Matching procedure

---
# In a nutshell
## In a nutshell

The manual procedure steps are:

Expand All @@ -12,8 +11,7 @@ The manual procedure steps are:
- run the `acquire users` command
- if any errors, adjust the exceptions in the `secrets/make_matches_config.json` file, and re-run the account matching script.

---
# In details
## In details

This procedure consists in making matches between the DRAC user account and the Mila acocunts.

Expand All @@ -22,7 +20,7 @@ This procedure consists in making matches between the DRAC user account and the

After that, the `users` collection of mongoDB contains the aggregated users database.

## Access rights
### Access rights

The operator executing the account matching procedure must have wite access to the DRAC folder.

Expand All @@ -31,12 +29,12 @@ Two possible scenarios :
- have write access to the running SARC server (production server)
- use SARC from a local machine, with a SSH connection to the production server (see below). **This is the prefered method.**

### Remote access to MongoDB (via SSH tunneling)
#### Remote access to MongoDB (via SSH tunneling)

#### SSH config
##### SSH config
Refer to `remote_mongo_access.md` for ssh connection with port redirection, to connect to mongoDB form the local machine.

#### SARC config file
##### SARC config file
To use the remote mongoDB connection, tunneled from localhost:27018, the `mongo` section in the config file like this:

```
Expand All @@ -46,7 +44,7 @@ To use the remote mongoDB connection, tunneled from localhost:27018, the `mongo`
},
```

## data source 1: Mila LDAP credentials
### data source 1: Mila LDAP credentials

The credentials for the Mila LDAP are in the `secrets/ldap` folder.

Expand All @@ -61,21 +59,21 @@ They are refered to in the ldap section of the sarc config file :

```

## data source 2: DRAC account files
### data source 2: DRAC account files

Compute Canada must provide 2 CSV files:
- One "members" file
- One "roles" file

### copy the files in the right directory
#### copy the files in the right directory

The two file must be copied to the `secrets/account_matching/` folder of SARC, on the server or the local machine, depending on the scenario.

### Configuration file
#### Configuration file



## Exceptions handling
### Exceptions handling

The exception are manually handled in the `secrets/make_matches_config.json` file.

Expand All @@ -101,9 +99,9 @@ The procedure is:
- run the matching script
- if there are mathcing errors, modify `make_matches_config.json` accordingly and re-run the matching script.

## Run the matching script
### Run the matching script

From the SARC folder:
```
$ SARC_CONFIG=<path_to_config_file> poetry run sarc acquire users
```
```
26 changes: 26 additions & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Configuration file for the Sphinx documentation builder.
#
# For the full list of built-in configuration values, see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html

# -- Project information -----------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information

project = "SARC"
copyright = "2023, Mila"
author = "Mila"

# -- General configuration ---------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration

extensions = ["myst_parser"]

templates_path = ["_templates"]
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]


# -- Options for HTML output -------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output

html_theme = "sphinx_rtd_theme"
html_static_path = ["_static"]
21 changes: 21 additions & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
.. SARC documentation master file, created by
sphinx-quickstart on Mon Jul 24 14:36:51 2023.
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.

Welcome to SARC's documentation!
================================

.. toctree::
:maxdepth: 2
:caption: Contents:

account_matching
account_matching_manual_procedure
deployment
remote_mongo_access
secrets
scripts/README
scripts/remote/README
scripts/systemd/README
scripts/deploy/README
7 changes: 4 additions & 3 deletions docs/remote_mongo_access.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Remove Mongo access

# MongoDB port tunneling
## MongoDB port tunneling

With an SSH access to the production machine, you can easilly tunnel the mongoDB. Example in the `~/.ssh/config` file:

Expand All @@ -9,7 +10,7 @@ Host sarc
LocalForward 27018 127.0.0.1:27017
```

# SARC config file
## SARC config file

Simply modify the config JSON file you use:

Expand All @@ -19,4 +20,4 @@ Simply modify the config JSON file you use:
"database_name": "sarc"
},

```
```
3 changes: 3 additions & 0 deletions docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
sphinx<7
myst-parser<3
sphinx-rtd-theme<2
9 changes: 9 additions & 0 deletions docs/scripts/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Setup Scripts

## remote

[These scripts](remote/README.md) must be run from a computer from which you have ssh access to the sarc server.

## systemd

[These services](systemd/README.md) must be injected in systemd; see the [deployment doc](../deployment.md) and the [systemd README.md](systemd/README.md)
10 changes: 10 additions & 0 deletions docs/scripts/deploy/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Deploy scripts

`sudo install_services.sh` will install and start the services for SARC.

## Prerequisite: podman containers

The podman containers must have been created before `sarc_contaners.service` can be started and/or enabled on boot.
See the [deployment doc](../../deployment.md) for further info.


27 changes: 27 additions & 0 deletions docs/scripts/remote/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Remote scripts

## serverinit.sh
Installs base packages on a bare new OS.
SSH access and sudo rights on the target server needed.

```
$ chmod +x serverinit.sh
$ ./serverinit.sh <server>
```

## mongo.sh
Install, start and stop mongo package on the server

```
$ ./mongo.sh <server> [start|stop|status]
```

You **MUST** run `./mongo.sh <server> install` once before deploying systemd scripts.

## setup_github_keys.sh
Generate the ssh "deploy keys" needed to deploy the code to the server
```
$ ./setup_github_keys.sh <server>
```

See [The deployment doc](../../deployment.md) for more info.
9 changes: 9 additions & 0 deletions docs/scripts/systemd/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# systemd services

These service scripts must be linked from `/etc/systemd/system/`

See [The deploy README](../deploy/README.md) for more info.

- Execute jobs scraper with `systemctl start sarc_scrapers.service` (one-shot)
- Activate the timer with `systemctl start sarc_scrapers.timer`
- Enable at boot with `systemctl enable sarc_scrapers.timer`
Loading