From b077a678de652d06708c8eb3546ac7d0357dd341 Mon Sep 17 00:00:00 2001 From: Stefan Appelhoff Date: Wed, 10 Jan 2024 16:30:05 +0100 Subject: [PATCH 1/8] misc fixes and start doc --- tools/README.md | 1 + ...{bep_gant_chart.py => bep_gantt_html_create.py} | 14 ++++++++------ ...id_bep_gantt.py => bep_gantt_mermaid_insert.py} | 7 ++++--- 3 files changed, 13 insertions(+), 9 deletions(-) rename tools/{bep_gant_chart.py => bep_gantt_html_create.py} (92%) rename tools/{insert_mermaid_bep_gantt.py => bep_gantt_mermaid_insert.py} (95%) diff --git a/tools/README.md b/tools/README.md index e9a64d43..4fd5b455 100644 --- a/tools/README.md +++ b/tools/README.md @@ -16,3 +16,4 @@ This README file describes the tools under the `/tools` directory of the bids-we 1. From the command line, navigate to `tools`, and then run `make all` 1. Clean up, check the newly added files, commit +## Update the Gantt chart of completed BEPs diff --git a/tools/bep_gant_chart.py b/tools/bep_gantt_html_create.py similarity index 92% rename from tools/bep_gant_chart.py rename to tools/bep_gantt_html_create.py index f0530a5b..a4b681de 100644 --- a/tools/bep_gant_chart.py +++ b/tools/bep_gantt_html_create.py @@ -1,4 +1,4 @@ -"""Creates a gant chart for the completed BEPs. +"""Creates a Gantt chart for the completed BEPs. Also include a timeline of the main BIDS events. """ @@ -10,7 +10,7 @@ import pandas as pd import plotly.express as px import plotly.graph_objects as go -import ruamel.yaml as yaml +from ruamel.yaml import YAML from pyzotero import zotero INCLUDE_PATCHES = False @@ -31,7 +31,8 @@ def create_bep_timeline() -> type[go.Figure]: completd_beps = data_dir() / "beps_completed.yml" with open(completd_beps, "r") as f: - data = yaml.safe_load(f) + yaml = YAML(typ="safe", pure=True) + data = yaml.load(f) df = [] @@ -140,9 +141,9 @@ def add_publications_to_timeline(fig: go.Figure) -> type[go.Figure]: dois = [] dates = [] for item in items: - titles.append(item["data"].get("title")) - dois.append(item["data"]["DOI"]) - dates.append(item["data"]["date"]) + titles.append(item["data"].get("title", "n/a")) + dois.append(item["data"].get("DOI", "n/a")) + dates.append(item["data"].get("date", "n/a")) fig.add_trace( go.Scatter( @@ -191,6 +192,7 @@ def main(): fig.show() # save as html + # NOTE: This file is ignored in git (see .gitignore) fig.write_html(root_dir() / "_pages" / "bids_timeline.html") diff --git a/tools/insert_mermaid_bep_gantt.py b/tools/bep_gantt_mermaid_insert.py similarity index 95% rename from tools/insert_mermaid_bep_gantt.py rename to tools/bep_gantt_mermaid_insert.py index b6aa629b..b8fa65ad 100644 --- a/tools/insert_mermaid_bep_gantt.py +++ b/tools/bep_gantt_mermaid_insert.py @@ -1,10 +1,10 @@ -"""Creates a gant chart for the completed BEPs""" +"""Creates a Gantt chart for the completed BEPs""" from __future__ import annotations from pathlib import Path import pandas as pd -import ruamel.yaml as yaml +from ruamel.yaml import YAML from rich import print @@ -30,7 +30,8 @@ def get_bep_timeline() -> pd.DataFrame: completd_beps = data_dir() / "beps_completed.yml" with open(completd_beps, "r") as f: - data = yaml.safe_load(f) + yaml = YAML(typ="safe", pure=True) + data = yaml.load(f) df = [] From 95727c0805b7325eeb93fd5b57e574b7765f6d38 Mon Sep 17 00:00:00 2001 From: Stefan Appelhoff Date: Wed, 10 Jan 2024 16:34:54 +0100 Subject: [PATCH 2/8] manage black exclude via gitignore --- .gitignore | 2 ++ pyproject.toml | 10 +--------- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/.gitignore b/.gitignore index 08538db2..9fb74c12 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,5 @@ __pycache__ .sass-cache tools/inputs tools/*.html +env/ +_pages/bids_timeline.html diff --git a/pyproject.toml b/pyproject.toml index 8389af11..a5f16bd3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,11 +1,3 @@ [tool.black] line-length = 99 -target-version = ['py39'] -exclude = ''' -( - /( - \.git - | env - )/ -) -''' +target-version = ["py39"] From 4e6c0ba95da5f4f96d40d746f3ebfcb4e5a237bc Mon Sep 17 00:00:00 2001 From: Stefan Appelhoff Date: Wed, 10 Jan 2024 16:36:24 +0100 Subject: [PATCH 3/8] switch precommit large file check back on, license year --- .pre-commit-config.yaml | 2 +- LICENSE | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index a92a437c..980d4299 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -7,7 +7,7 @@ repos: - id: trailing-whitespace - id: end-of-file-fixer - id: check-yaml - # - id: check-added-large-files + - id: check-added-large-files - id: check-case-conflict - repo: https://github.com/codespell-project/codespell diff --git a/LICENSE b/LICENSE index e79d0439..7ee92919 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ Attribution 4.0 International -Copyright (c) 2020-2023, BIDS Contributors. +Copyright (c) 2020-2024, BIDS Contributors. ======================================================================= From 5684a3aeb98e12115e44b0234b6eaaf3097327eb Mon Sep 17 00:00:00 2001 From: Stefan Appelhoff Date: Wed, 10 Jan 2024 16:44:09 +0100 Subject: [PATCH 4/8] add documentation --- tools/README.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tools/README.md b/tools/README.md index 4fd5b455..f0576aa2 100644 --- a/tools/README.md +++ b/tools/README.md @@ -17,3 +17,14 @@ This README file describes the tools under the `/tools` directory of the bids-we 1. Clean up, check the newly added files, commit ## Update the Gantt chart of completed BEPs + +There are two ways of creating Gantt charts for a BIDS timeline. +First install all Python requirements under `tools/requirements.txt`. +Then, use one of the following two methods: + +1. `python -u tools/bep_gantt_html_create` creates a file: `_pages/bids_timeline.html` that you can inspect in your browser. + This file depends on the `tools/timeline.csv` data, which you should keep up to date. +1. `python -u tools/bep_gantt_mermaid_insert` directly inserts code for a "mermaid" Gantt chart into the Get Involved page of the website. + You can inspect how that chart looks by building the website using Jekyll and serving locally. + This code depends on data from the files `beps_completed.yml` files in the `_data` directory. + You should keep that file up to date. From 4e5c0f3b81c72d6f5b6148d924569fd172dde884 Mon Sep 17 00:00:00 2001 From: Stefan Appelhoff Date: Wed, 10 Jan 2024 16:46:53 +0100 Subject: [PATCH 5/8] fix link --- _layouts/index.html | 2 +- _pages/index.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/_layouts/index.html b/_layouts/index.html index ed9b7ec7..3516f9c0 100644 --- a/_layouts/index.html +++ b/_layouts/index.html @@ -106,7 +106,7 @@ {% if site.show_footer %}