Skip to content

Commit 6646987

Browse files
enryHsayalaruano
andauthored
Style and format codebase (#131)
* 🎨 format markdowns * 🎨 docstrings to 90 characters and remove whitespaces * 🔧 set line length to 90 characters * 🎨 split comments, add comments, remove more whitespace, add more docstrings * 🎨 write strings on two line and let Python concatenate theses * 🎨 snake_case * 🎨 raise ValueError if unknown type is provided alternatively we could use a meaningful default * 🎨 specify encoding explicitly * 🎨 use textwrap to keep indentation * 🐛 with textwrap the text cannot contain new line statements * 🎨 adjust comments and docstrings to line-length * 🔧 add jupytext configuration for notebooks to project * ✅ update example report files so test pass (reviewed changes are only style of .py files) * 🎨 continue reformatting of streamlit_report.py * 🎨 remove one level of indentation * 🎨 docstring and f-string formatting - leave out most multiline string for now (which need dedenting) - one whitespace update in tests * 🎨 encoding and whitespace updates * 🐛 add missing argument to abc for reports * 🎨 textwrap code or html blocks - sometime indent and dedent has to be used - one typo (altair plot, not plotly plot corrected) - new line before python code block in qmd files * 🎨 keep urls at the top - maybe 'Verschlimmbessern': footer can be hard to read (pdf) - needed to use escaping of {} using unicode: \u007b is { and \u007d is } - 🐛 jupyter used relative import -> changed to URL link of LOGO - unify MONA mentioning (pdf) * 🎨 limit remaining lines to 90 characters * 🎨 shorten docstrings and comments, implement lazy logging lazy logging is recommended (only a warning): https://pylint.readthedocs.io/en/latest/user_guide/messages/warning/logging-fstring-interpolation.html * 🎨 remove trailing white-space from streamlit footer * 🚚 add constants file to keep these central * 🎨 streamlit footer in utils? use central constants for footer, dedent * 🎨 add initialization of dictionary in body of function * 🎨 add timeout to get request -> will 60 seconds always be enough? * 🎨 dedent and slightly modify completion message * 🎨 line lenght, lazy logging and raising exceptions from exception * 🎨 module and docstrings, comments splitting and removing unnecessary code * 🎨 lazy logging + exe_info and Error messaging splitting (line length) * 🎨 module string, line length, unused arguments, * 🎨 lazy logging and reporting of error info for error lazy-logging: https://pylint.readthedocs.io/en/latest/user_guide/messages/warning/logging-not-lazy.html exc_info: https://docs.python.org/3/library/logging.html#logging.Logger.debug * 🐛 Handle error for loading static images from a URL in streamlit reports * 📝 Update md files for the yaml examples on the documentation * 🐛 Fix desciption from the EMP config example * 🐛 Fix code to load images from URLs in streamlit reports * Trigger GitHub actions to avoid connection error to download tinytex * 🎨🔧 let ruff check for line lenght and other potential bugs, add vscode config update config: - fixed line length to 88 as default - ensure line lenght is checked in tests * 🐛 Ollama chatbot example - dedent should be called only once - each block needs to be on the level of where it is supposed to be used (in the multiline f-string) * 🐛 use existing config file, not the local one generated by chabot notebook --------- Co-authored-by: sayalaruano <[email protected]>
1 parent 6d29572 commit 6646987

File tree

41 files changed

+2189
-1060
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+2189
-1060
lines changed

.github/workflows/cdci.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,14 @@ jobs:
118118
echo "Error: One or more protected files have been modified."
119119
exit 1
120120
fi
121+
- name: check streamlit report files for chatbot API
122+
run: |
123+
vuegen -c docs/example_config_files/Chatbot_example_config.yaml -output_dir tests/report_examples/chat_bot
124+
if git diff tests/report_examples | grep .; then
125+
echo Failed for report: $format
126+
echo "Error: One or more protected files have been modified."
127+
exit 1
128+
fi
121129
- name: check for changes in report files
122130
run: |
123131
# write streamlit report to test folder

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ cython_debug/
116116
# Temporary files
117117
logs/
118118
vuegen/logs/
119-
./streamlit_report/
119+
streamlit_report/
120120
!tests/report_examples
121121
quarto_report/
122122
output_docker/

.vscode/settings.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"editor.rulers": [88, 100, 120]
3+
}

docs/README.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
# Docs creation
22

3-
In order to build the docs you need to
3+
In order to build the docs you need to
44

5-
1. Install sphinx and additional support packages
6-
2. Build the package reference files
7-
3. Run sphinx to create a local html version
5+
1. Install sphinx and additional support packages
6+
2. Build the package reference files
7+
3. Run sphinx to create a local html version
88

99
The documentation is build using readthedocs automatically.
1010

@@ -18,12 +18,13 @@ poetry install --with docs
1818

1919
## Build docs using Sphinx command line tools
2020

21-
Command to be run from `path/to/docs`, i.e. from within the `docs` package folder:
21+
Command to be run from `path/to/docs`, i.e. from within the `docs` package folder:
2222

2323
Options:
24-
- `--separate` to build separate pages for each (sub-)module
2524

26-
```bash
25+
- `--separate` to build separate pages for each (sub-)module
26+
27+
```bash
2728
# pwd: docs
2829
# apidoc
2930
sphinx-apidoc --force --implicit-namespaces --module-first -o reference ../src/vuegen
@@ -38,4 +39,3 @@ The README is included in the `Overview` section of the docs. We created a [Pyth
3839
Relative links are used in the main README, which need to be resolved when building. It's
3940
possible to include the a `relative-docs` option if one uses `index.md` ([see docs](https://myst-parser.readthedocs.io/en/latest/faq/index.html#include-a-file-from-outside-the-docs-folder-like-readme-md)). This does not work
4041
with `href` links, only native markdown links.
41-

docs/example_config_files/Chatbot_example_config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
report:
22
title: Chatbot example
33
description: >
4-
A chatbot exaple.
4+
A chatbot example.
55
sections:
66
- title: ChatBot test
77
subsections:

docs/example_config_files/Earth_microbiome_vuegen_demo_notebook_config.yaml

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
report:
22
title: Earth Microbiome Vuegen Demo Notebook
3-
description: "The Earth Microbiome Project (EMP) is a systematic attempt to characterize\
4-
\ global microbial taxonomic and functional diversity for the benefit of the planet\
5-
\ and humankind. \n It aimed to sample the Earth\u2019s microbial communities\
6-
\ at an unprecedented scale in order to advance our understanding of the organizing\
7-
\ biogeographic principles that govern microbial community structure. \n The\
8-
\ EMP dataset is generated from samples that individual researchers have compiled\
9-
\ and contributed to the EMP. \n The result is both a reference database giving\
10-
\ global context to DNA sequence data and a framework for incorporating data from\
11-
\ future studies, fostering increasingly complete characterization of Earth\u2019\
12-
s microbial diversity.\n \n You can find more information about the Earth Microbiome\
13-
\ Project at https://earthmicrobiome.org/ and in the [original article](https://www.nature.com/articles/nature24621).\n"
3+
description: >
4+
The Earth Microbiome Project (EMP) is a systematic attempt to characterize global
5+
microbial taxonomic and functional diversity for the benefit of the planet and humankind.
6+
It aimed to sample the Earth’s microbial communities at an unprecedented scale in order to
7+
advance our understanding of the organizing biogeographic principles that govern microbial
8+
community structure. The EMP dataset is generated from samples that individual researchers
9+
have compiled and contributed to the EMP. The result is both a reference database giving
10+
global context to DNA sequence data and a framework for incorporating data from future
11+
studies, fostering increasingly complete characterization of Earth’s microbial diversity.
12+
You can find more information about the Earth Microbiome Project at https://earthmicrobiome.org/
13+
and in the original article at https://www.nature.com/articles/nature24621.
1414
graphical_abstract: https://raw.githubusercontent.com/ElDeveloper/cogs220/master/emp-logo.svg
1515
logo: https://raw.githubusercontent.com/ElDeveloper/cogs220/master/emp-logo.svg
1616
sections:

docs/vuegen_basic_case_study_configfile.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
# Predefined Directory Case Study - Configuration File
22

3-
The [configuration file](https://github.com/Multiomics-Analytics-Group/vuegen/blob/main/docs/example_config_files/Basic_example_vuegen_demo_notebook_config.yaml) of the basic case study using a predefined directory is presented below:
3+
The [configuration file](https://github.com/Multiomics-Analytics-Group/vuegen/blob/main/docs/example_config_files/Basic_example_vuegen_demo_notebook_config.yaml) of the basic case study using a predefined directory is presented below:
44

55
```yaml
66
report:
77
title: Basic Example Vuegen Demo Notebook
88
description: A general description of the report.
9-
graphical_abstract: https://raw.githubusercontent.com/Multiomics-Analytics-Group/vuegen/main/docs/images/vuegen_logo.svg
10-
logo: https://raw.githubusercontent.com/Multiomics-Analytics-Group/vuegen/main/docs/images/vuegen_logo.svg
9+
graphical_abstract: https://raw.githubusercontent.com/Multiomics-Analytics-Group/vuegen/main/docs/images/vuegen_logo.png
10+
logo: https://raw.githubusercontent.com/Multiomics-Analytics-Group/vuegen/main/docs/images/vuegen_logo.png
1111
sections:
1212
- title: Plots
1313
description: This section contains example plots.

docs/vuegen_earth_microbiome_case_study_configfile.md

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,17 @@ The [configuration file](https://github.com/Multiomics-Analytics-Group/vuegen/bl
55
```yaml
66
report:
77
title: Earth Microbiome Vuegen Demo Notebook
8-
description: "The Earth Microbiome Project (EMP) is a systematic attempt to characterize\
9-
\ global microbial taxonomic and functional diversity for the benefit of the planet\
10-
\ and humankind. \n It aimed to sample the Earth\u2019s microbial communities\
11-
\ at an unprecedented scale in order to advance our understanding of the organizing\
12-
\ biogeographic principles that govern microbial community structure. \n The\
13-
\ EMP dataset is generated from samples that individual researchers have compiled\
14-
\ and contributed to the EMP. \n The result is both a reference database giving\
15-
\ global context to DNA sequence data and a framework for incorporating data from\
16-
\ future studies, fostering increasingly complete characterization of Earth\u2019\
17-
s microbial diversity.\n \n You can find more information about the Earth Microbiome\
18-
\ Project at https://earthmicrobiome.org/ and in the [original article](https://www.nature.com/articles/nature24621).\n"
8+
description: >
9+
The Earth Microbiome Project (EMP) is a systematic attempt to characterize global
10+
microbial taxonomic and functional diversity for the benefit of the planet and humankind.
11+
It aimed to sample the Earth’s microbial communities at an unprecedented scale in order to
12+
advance our understanding of the organizing biogeographic principles that govern microbial
13+
community structure. The EMP dataset is generated from samples that individual researchers
14+
have compiled and contributed to the EMP. The result is both a reference database giving
15+
global context to DNA sequence data and a framework for incorporating data from future
16+
studies, fostering increasingly complete characterization of Earth’s microbial diversity.
17+
You can find more information about the Earth Microbiome Project at https://earthmicrobiome.org/
18+
and in the original article at https://www.nature.com/articles/nature24621.
1919
graphical_abstract: https://raw.githubusercontent.com/ElDeveloper/cogs220/master/emp-logo.svg
2020
logo: https://raw.githubusercontent.com/ElDeveloper/cogs220/master/emp-logo.svg
2121
sections:
@@ -128,8 +128,7 @@ sections:
128128
component_type: PLOT
129129
plot_type: STATIC
130130
- title: Shanon entropy analysis
131-
description: This subsection contains the Shannon entropy analysis of the EMP
132-
dataset.
131+
description: This subsection contains the Shannon entropy analysis of the EMP dataset.
133132
components:
134133
- title: Specificity of sequences and higher taxonomic groups for environment
135134
file_path: https://raw.githubusercontent.com/biocore/emp/master/methods/images/figure4_entropy.png

pyproject.toml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,3 +74,20 @@ vuegen = "vuegen.__main__:main"
7474

7575
[tool.isort]
7676
profile = "black"
77+
78+
[tool.jupytext]
79+
formats = "ipynb,py:percent"
80+
81+
[tool.ruff]
82+
# Allow lines to be as long as:
83+
line-length = 88
84+
85+
[tool.ruff.lint]
86+
# https://docs.astral.sh/ruff/tutorial/#rule-selection
87+
# 1. Enable flake8-bugbear (`B`) rules
88+
# 2. Enable pycodestyle (`E`) errors and (`W`) warnings
89+
# 3. Pyflakes (`F`) errors
90+
extend-select = ["E", "W", 'F', 'B']
91+
92+
[tool.black]
93+
line-length = 88

setup.cfg

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[flake8]
2+
exclude = docs
3+
max-line-length = 88
4+
aggressive = 2

0 commit comments

Comments
 (0)