From 3d785fb9d270291c85cae5e725a57752201383cd Mon Sep 17 00:00:00 2001 From: Remi Gau Date: Wed, 20 Mar 2024 16:17:37 -0400 Subject: [PATCH 1/3] add codespell, update hooks, run pre-commit --- .codespellrc | 4 ++++ .pre-commit-config.yaml | 8 ++++++-- docs/01_introduction.md | 4 ++-- docs/30_schema.md | 4 ++-- docs/41_create_new_protocol.md | 2 +- docs/42_adopt_assessments.md | 10 +++++----- docs/46_tools.md | 6 +++--- mkdocs.yml | 4 ++-- terms/Field | 1 - terms/unitOptions | 2 +- 10 files changed, 26 insertions(+), 19 deletions(-) create mode 100644 .codespellrc diff --git a/.codespellrc b/.codespellrc new file mode 100644 index 0000000000..25245058fe --- /dev/null +++ b/.codespellrc @@ -0,0 +1,4 @@ +[codespell] +skip = env,venv,*.svg +ignore-words-list = HSI +builtin = clear,rare diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index c429bfa6d9..0cf4df782f 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -2,13 +2,17 @@ # See https://pre-commit.com/hooks.html for more hooks repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v2.0.0 + rev: v4.5.0 hooks: - id: trailing-whitespace - id: end-of-file-fixer - id: check-yaml - id: check-added-large-files - repo: https://github.com/psf/black - rev: 19.3b0 + rev: 24.3.0 hooks: - id: black +- repo: https://github.com/codespell-project/codespell + rev: v2.2.6 + hooks: + - id: codespell diff --git a/docs/01_introduction.md b/docs/01_introduction.md index 524ebf9732..49561ef470 100644 --- a/docs/01_introduction.md +++ b/docs/01_introduction.md @@ -35,7 +35,7 @@ these questionnaires. However, these resources are often used to make data consistent and reusable after, rather than during data collection. However, harmonizing data after acquisition is resource intensive and this approach can create a mismatch between collected and submitted data due to human error during -the harmonization process. To faciliate tedious harmonization efforts, several +the harmonization process. To facilitate tedious harmonization efforts, several projects, over the last two decades, have developed technologies to automatically or interactively align and harmonize data elements (e.g., BIRN mediator, OpenRefine). @@ -126,7 +126,7 @@ displayed to the user and under which conditions, should be computed The ReproSchema also allows for internationalization and multiple languages support -by making it very easy to keep everything the same +by making it very easy to keep everything the same except the language displayed by the user interface. Finally ReproSchema allows tracking of variations and version of different assessments diff --git a/docs/30_schema.md b/docs/30_schema.md index 2d42c8b33b..5ff213b736 100644 --- a/docs/30_schema.md +++ b/docs/30_schema.md @@ -9,7 +9,7 @@ include: We have used schema.org classes and properties where it maps on to the needs of the model and extended the model with NIDM elements to harmonize across ReproNim projects. -1. Allowing for structued nested elements in a schema +1. Allowing for structured nested elements in a schema `Protocol > Activity > [Activity | Field > ResponseOption]`. This nested structure provides a flexible schema to represent nested activities, which are common in biomedical and other domains. @@ -38,7 +38,7 @@ used. participant. 1. Allowing for user interface (UI) elements that allow interaction between the schema and any implementation that allows collecting data using the schema. By providing -some additional UI elements the provider can guide an implementor to allow for +some additional UI elements the provider can guide an implementer to allow for more complex data collection behavior. The [ReproSchema-UI](https://repronim.org/reproschema-ui) is a prototype implementation of an UI that leverages these diff --git a/docs/41_create_new_protocol.md b/docs/41_create_new_protocol.md index f5f8a63e56..c40ca4c6ca 100644 --- a/docs/41_create_new_protocol.md +++ b/docs/41_create_new_protocol.md @@ -6,7 +6,7 @@ Ready for your first ReproSchema project?! We are going to use the [Reproschema 1. Prerequisite: Ensure you have Git and Cookiecutter installed on your system. If not, please refer to the installation guides for Git and Cookiecutter. 2. Generate Your Repository: Use the Reproschema Protocol Cookiecutter to create a new repository for your research protocol. Run the following command in your terminal: - + ```bash cookiecutter gh:ReproNim/reproschema-protocol-cookiecutter ``` diff --git a/docs/42_adopt_assessments.md b/docs/42_adopt_assessments.md index e164a0452c..e32068faa9 100644 --- a/docs/42_adopt_assessments.md +++ b/docs/42_adopt_assessments.md @@ -1,4 +1,4 @@ -# Adopting Assessments from the reproschema-library +# Adopting Assessments from the reproschema-library This part focuses on how to select and integrate assessments from the reproschema-library into your research protocol, an essential step in crafting a comprehensive study. The chosen assessments are to be placed in the `activities` folder within your repository. This folder serves as the central hub for various assessments or activities that collectively form your research protocol. @@ -6,7 +6,7 @@ Each activity or assessment within this `activities` folder is typically structu To illustrate this process, we will use two specific types of assessments from [reproschema-library](https://github.com/ReproNim/reproschema-library): `demographics` and `psychological questions`. The latter represents a composite assessment created from multiple pre-existing assessments within the library. This example demonstrates how to combine different elements from the library to construct a bespoke assessment tailored to the unique demands of your research protocol. -## Step 1: Understand the structure of a *_schema file throught this [exemplar file](https://github.com/ReproNim/reproschema-protocol-cookiecutter/blob/main/%7B%7Bcookiecutter.protocol_name%7D%7D/activities/Activity1/activity1_schema) +## Step 1: Understand the structure of a *_schema file through this [exemplar file](https://github.com/ReproNim/reproschema-protocol-cookiecutter/blob/main/%7B%7Bcookiecutter.protocol_name%7D%7D/activities/Activity1/activity1_schema) 1. **Context (@context)**: This field provides references to the context definitions. In this schema, it links to the generic context of ReproSchema and the specific context for the items in the repository, defined by the URL with the "rl" key. This context helps to interpret the terms used within the schema. 2. **Type (@type)**: Defined as "reproschema:Activity," this indicates the nature of the document, specifying that it is an activity within the ReproSchema framework. @@ -34,7 +34,7 @@ This step involves precise modifications, particularly in the `@context` and `ad Labeling this link as "demo" directs the schema to the location in the ReproSchema-library where items for demographics and background information are defined. We use the link with a specific commit ID to ensure the consistency of the assessment version. This contextual link allows the schema to access the detailed structures and definitions needed for each demographic item. -2. **Customizing "addProperties" for Demographic Variables**: +2. **Customizing "addProperties" for Demographic Variables**: In the "addProperties" section, we define each variable that corresponds to a demographic question. For example: @@ -141,8 +141,8 @@ Different from `demograpgics`, `psychological_questionnaire_schema` combines ass "isAbout": "demo:clinical_history_psychiatry" } ``` - + - The `order` array specifies the sequence in which these assessments will appear in the questionnaire, ensuring a logical flow for participants. - The `shuffle` setting is `false`, maintaining the defined order, and allow includes functionalities like auto-advance between assessments and data export. -See the outcome [here](https://github.com/ReproNim/reproschema-demo-protocol/blob/main/activities/2_psychological/psychological_questionnaire_schema) \ No newline at end of file +See the outcome [here](https://github.com/ReproNim/reproschema-demo-protocol/blob/main/activities/2_psychological/psychological_questionnaire_schema) diff --git a/docs/46_tools.md b/docs/46_tools.md index 78e813b39a..aca854c5c9 100644 --- a/docs/46_tools.md +++ b/docs/46_tools.md @@ -1,6 +1,6 @@ # Toolkit -In the world of research data management, flexibility and compatibility are key. Understanding this, we provide specialized tools designed to create, validata schemas, and convert data between ReproSchema format and REDCap CSV format. Whether you're transitioning from REDCap to ReproSchema or vice versa, these tools ensure a smooth and efficient conversion process, preserving the integrity and structure of your data. +In the world of research data management, flexibility and compatibility are key. Understanding this, we provide specialized tools designed to create, validate schemas, and convert data between ReproSchema format and REDCap CSV format. Whether you're transitioning from REDCap to ReproSchema or vice versa, these tools ensure a smooth and efficient conversion process, preserving the integrity and structure of your data. ## Install reproschema-py @@ -52,7 +52,7 @@ reproschema reproschema2redcap cd reproschema-demo-protocol pwd ``` - + In this case, the output from `pwd` (which shows your current directory path)should be your ``. - ``: The name of the output CSV file where the converted data will be saved. @@ -90,4 +90,4 @@ The `redcap2reproschema` function has been integrated into a CLI tool, use the f reproschema redcap2reproschema path/to/your_redcap_data_dic.csv path/to/your_redcap2rs.yaml ``` -Those tools can also be used as Python functions. For detailed instructions, please visit [reproschema-py](https://github.com/ReproNim/reproschema-py). +Those tools can also be used as Python functions. For detailed instructions, please visit [reproschema-py](https://github.com/ReproNim/reproschema-py). diff --git a/mkdocs.yml b/mkdocs.yml index d80d83b113..9a56d46a96 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -20,8 +20,8 @@ nav: - Project structure: "20_project_structure.md" - Schema: "30_schema.md" - User Guide: - - Create a research protocol: "41_create_new_protocol.md" - - Adopt assessments from the library: "42_adopt_assessments.md" + - Create a research protocol: "41_create_new_protocol.md" + - Adopt assessments from the library: "42_adopt_assessments.md" - Create new assessments for a protocol: "43_create_new_assess.md" - Add a feedback section: "44_setup_feedback.md" - Finalize the protocol: "45_finalize_protocol.md" diff --git a/terms/Field b/terms/Field index 9e62b8c996..f8b86fa396 100644 --- a/terms/Field +++ b/terms/Field @@ -139,4 +139,3 @@ } ] } - diff --git a/terms/unitOptions b/terms/unitOptions index c25a5c2c2b..c3d1b8aba7 100644 --- a/terms/unitOptions +++ b/terms/unitOptions @@ -9,4 +9,4 @@ "@id": "reproschema:UnitOption" } ] -} \ No newline at end of file +} From e9cd1772dc4b51ea374fc7c41958758a285143e9 Mon Sep 17 00:00:00 2001 From: Remi Gau Date: Wed, 20 Mar 2024 16:21:55 -0400 Subject: [PATCH 2/3] add CI to run and update precommit --- .github/dependabot.yml | 9 ++++ .github/workflows/run_precommit.yml | 15 ++++++ .github/workflows/update_precommit_hooks.yml | 53 ++++++++++++++++++++ 3 files changed, 77 insertions(+) create mode 100644 .github/dependabot.yml create mode 100644 .github/workflows/run_precommit.yml create mode 100644 .github/workflows/update_precommit_hooks.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000000..5ab0ddfbf7 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,9 @@ +--- +# Documentation +# https://docs.github.com/en/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file +version: 2 +updates: +- package-ecosystem: github-actions + directory: / + schedule: + interval: monthly diff --git a/.github/workflows/run_precommit.yml b/.github/workflows/run_precommit.yml new file mode 100644 index 0000000000..97100d0bd4 --- /dev/null +++ b/.github/workflows/run_precommit.yml @@ -0,0 +1,15 @@ +--- +name: pre-commit + +on: + pull_request: + push: + branches: [main] + +jobs: + pre-commit: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + - uses: pre-commit/action@v3.0.0 diff --git a/.github/workflows/update_precommit_hooks.yml b/.github/workflows/update_precommit_hooks.yml new file mode 100644 index 0000000000..95f4d09b6b --- /dev/null +++ b/.github/workflows/update_precommit_hooks.yml @@ -0,0 +1,53 @@ +--- +name: Update precommit hooks + + +on: + +# Uses the cron schedule for github actions +# +# https://docs.github.com/en/free-pro-team@latest/actions/reference/events-that-trigger-workflows#scheduled-events +# +# ┌───────────── minute (0 - 59) +# │ ┌───────────── hour (0 - 23) +# │ │ ┌───────────── day of the month (1 - 31) +# │ │ │ ┌───────────── month (1 - 12 or JAN-DEC) +# │ │ │ │ ┌───────────── day of the week (0 - 6 or SUN-SAT) +# │ │ │ │ │ +# │ │ │ │ │ +# │ │ │ │ │ +# * * * * * + schedule: + - cron: 0 0 * 1,7 * # january and july + + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + +jobs: + update_precommit_hooks: + + # only run on upstream repo + if: github.repository_owner == 'SIMEXP' + + runs-on: ubuntu-latest + steps: + - name: Checkout repo + uses: actions/checkout@v4 + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: '3.12' + allow-prereleases: false + - name: Install pre-commit + run: pip install pre-commit + - name: Update pre-commit hooks + run: pre-commit autoupdate + - name: Create Pull Request + uses: peter-evans/create-pull-request@v5 + with: + commit-message: pre-commit hooks auto-update + base: main + token: ${{ secrets.GITHUB_TOKEN }} + delete-branch: true + title: '[BOT] update pre-commit hooks' + body: done via this [GitHub Action](https://github.com/${{ github.repository_owner }}/reproschema /blob/main/.github/workflows/update_precommit_hooks.yml) From 82ee64cf2fbe68a5cdde123e6b964fe1a68c1f42 Mon Sep 17 00:00:00 2001 From: Remi Gau Date: Wed, 20 Mar 2024 16:44:21 -0400 Subject: [PATCH 3/3] add more hooks --- .pre-commit-config.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 0cf4df782f..f1ffa3edbe 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -7,6 +7,8 @@ repos: - id: trailing-whitespace - id: end-of-file-fixer - id: check-yaml + - id: check-json + - id: check-ast - id: check-added-large-files - repo: https://github.com/psf/black rev: 24.3.0