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

see #7

Closed
wants to merge 115 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
115 commits
Select commit Hold shift + click to select a range
b19a86b
[pre-commit.ci] pre-commit autoupdate
pre-commit-ci[bot] Oct 10, 2022
9cfcef4
Merge pull request #27 from ReproNim/pre-commit-ci-update-config
satra Oct 31, 2022
4fcc568
[pre-commit.ci] pre-commit autoupdate
pre-commit-ci[bot] Feb 6, 2023
059f4b4
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Feb 6, 2023
31094ed
Merge pull request #28 from ReproNim/pre-commit-ci-update-config
satra Feb 6, 2023
ef27982
convert js to python
yibeichan Dec 25, 2023
142089e
add redcap2rs yaml template
yibeichan Dec 25, 2023
abd9c48
update yaml template
yibeichan Dec 25, 2023
675a4b2
update instruction to use redcap2reproschema.py
yibeichan Dec 25, 2023
1f8746d
add additional python package
yibeichan Dec 25, 2023
550db35
convert redcap2rs too from js to python
yibeichan Dec 25, 2023
7881305
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Dec 25, 2023
f3d8992
convert rs2redcap.js to python
yibeichan Dec 26, 2023
7fd5716
update cli.py with reproschema2redcap
yibeichan Dec 26, 2023
0c5d514
update readme for instruction
yibeichan Dec 26, 2023
3aae7fa
update readme for instruction
yibeichan Dec 26, 2023
5485e3d
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Dec 26, 2023
a3606fb
integrate redcap2rs in cli.py
yibeichan Dec 26, 2023
73da571
rewrite main() for cli use
yibeichan Dec 26, 2023
4906d76
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Dec 26, 2023
25932f8
update the template
yibeichan Dec 27, 2023
451af3c
major updates for converting
yibeichan Dec 27, 2023
5582c74
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Dec 27, 2023
4b93d47
add pyyaml to ga
yibeichan Dec 27, 2023
8739b10
Merge branch 'master' into redcap2reproschema
yibeichan Dec 27, 2023
4d86229
add pyyaml to setup.cfg
yibeichan Dec 27, 2023
14976ec
merge from master
yibeichan Dec 27, 2023
d5e4b8b
Update to ubuntu-latest
yibeichan Dec 27, 2023
47fb76b
Merge branch 'master' into redcap2reproschema
yibeichan Dec 27, 2023
91b7774
Merge branch 'master' into reproschema2redcap
yibeichan Dec 27, 2023
b6685e0
remove the github part
yibeichan Dec 28, 2023
3e72f25
add test for redcap2reproschema
yibeichan Dec 28, 2023
587b388
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Dec 28, 2023
a4e21a1
missing commits fpr cli
yibeichan Dec 28, 2023
0c96d56
fix the missing commit for cli
yibeichan Dec 28, 2023
8838e06
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Dec 28, 2023
ad2bab4
add cli for rs2redcap (need test data)
yibeichan Dec 28, 2023
ad7191a
remove protocol_variable_map
yibeichan Dec 28, 2023
163316c
Merge branch 'redcap2reproschema' of https://github.com/yibeichan/rep…
yibeichan Dec 28, 2023
e5e6091
fix protocol path
yibeichan Dec 28, 2023
f5dd9c5
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Dec 28, 2023
db29603
Merge pull request #30 from yibeichan/redcap2reproschema
yibeichan Jan 8, 2024
ba5a62b
add developer mode installation
yibeichan Jan 8, 2024
e4d20e1
Merge branch 'master' into reproschema2redcap
yibeichan Jan 8, 2024
f511f32
manually resolve conflicts
yibeichan Jan 8, 2024
8bdb8ec
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jan 8, 2024
3d48305
add test data for rs2redcap
yibeichan Jan 8, 2024
559e4f5
remove redundancy
yibeichan Jan 8, 2024
42314d9
merge conflict
yibeichan Jan 8, 2024
7ed30f1
move developer installation upwards
yibeichan Jan 8, 2024
9dd2952
Merge branch 'master' into reproschema2redcap
yibeichan Jan 8, 2024
b3071e5
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jan 8, 2024
9772d98
remove useless assertation
yibeichan Jan 8, 2024
d965f4b
Merge branch 'reproschema2redcap' of https://github.com/yibeichan/rep…
yibeichan Jan 8, 2024
aae814e
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jan 8, 2024
aab34e6
Merge pull request #31 from yibeichan/reproschema2redcap
yibeichan Jan 8, 2024
abba86a
fix minors
yibeichan Jan 8, 2024
683bb53
match test path
yibeichan Jan 8, 2024
f091fa8
reformating
yibeichan Jan 8, 2024
82851eb
fix matching with redcap
yibeichan Jan 9, 2024
74199d7
make better field mappings
yibeichan Jan 9, 2024
ce5af62
fix inputype start with select
yibeichan Jan 9, 2024
259a2e1
reformat choices
yibeichan Jan 9, 2024
bd84146
account for media as input
yibeichan Jan 10, 2024
01e6c1c
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jan 10, 2024
7e10185
Merge pull request #32 from yibeichan/master
yibeichan Jan 10, 2024
9f61bdb
allow choice to be non-integer
yibeichan Jan 11, 2024
ddfc6a7
Merge branch 'master' of https://github.com/yibeichan/reproschema-py
yibeichan Jan 11, 2024
87073fc
add yesno fieldtype conversion
yibeichan Jan 11, 2024
eee664a
fix missing argument in process_choice
yibeichan Jan 11, 2024
2491c47
fix language parse
yibeichan Jan 12, 2024
d6685a2
add print
yibeichan Jan 12, 2024
b95822f
add new test print
yibeichan Jan 12, 2024
34b7b99
another print test
yibeichan Jan 12, 2024
5b53e07
fix schema_map.get(key) error
yibeichan Jan 12, 2024
ffed151
fix presentation order in item
yibeichan Jan 12, 2024
6e583a6
Merge branch 'ReproNim:master' into master
yibeichan Jan 18, 2024
c8d915f
add id to items
yibeichan Jan 18, 2024
f9458c3
Merge branch 'master' of https://github.com/yibeichan/reproschema-py
yibeichan Jan 18, 2024
585b516
add test
yibeichan Jan 18, 2024
c86d80d
add test
yibeichan Jan 18, 2024
6ec5d71
remove BOM
yibeichan Jan 18, 2024
683f601
add prints to test
yibeichan Jan 18, 2024
9a35ee9
add prints to test
yibeichan Jan 18, 2024
7e93145
fix typo
yibeichan Jan 18, 2024
003e850
improve responseOptions
yibeichan Jan 19, 2024
37853b2
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jan 19, 2024
1533f11
get unique order
yibeichan Jan 19, 2024
891d580
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jan 19, 2024
9d3e929
Merge pull request #33 from yibeichan/master
yibeichan Jan 19, 2024
87f7a6a
add print for testing
yibeichan Jan 25, 2024
3162782
update clear_header
yibeichan Jan 25, 2024
64521d9
remove print
yibeichan Jan 25, 2024
4c1081a
fix order and other errors
yibeichan Feb 7, 2024
50fe4ce
change ui yesno to radio
yibeichan Feb 7, 2024
4359791
fix typo
yibeichan Feb 7, 2024
b17b5c7
update context, field->item, fix isVis
yibeichan Feb 22, 2024
ca3162d
remove useless due to failed validation
yibeichan Feb 23, 2024
4288f8a
remove visibility at the item level & remove matrixInfo
yibeichan Feb 23, 2024
57ca52e
fix choice
yibeichan Feb 25, 2024
82e2300
remove identifier
yibeichan Feb 28, 2024
3c7049f
fix conversion tests
yibeichan Apr 21, 2024
a60612f
remove test output
yibeichan Apr 21, 2024
e1e847d
change test output directory
yibeichan Apr 21, 2024
51d30b7
final improvments on tests
yibeichan Apr 21, 2024
ab7c051
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Apr 21, 2024
105489b
Merge pull request #37 from yibeichan/master
yibeichan Apr 29, 2024
78b8167
remove 3.7, add 3.11
yibeichan Apr 29, 2024
9af9054
add py3.12
yibeichan Apr 29, 2024
7379fcd
remove 3.12
yibeichan Apr 30, 2024
b4a8200
Update Versioneer to latest version
yibeichan May 2, 2024
b3bcb78
Update Versioneer to latest version
yibeichan May 2, 2024
6943e89
update action & python version
yibeichan May 2, 2024
7f378ec
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] May 2, 2024
b227e12
Merge pull request #38 from ReproNim/enh/py-version
yibeichan May 2, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
reproschema/_version.py export-subst
8 changes: 4 additions & 4 deletions .github/workflows/pythonpackage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [macos-latest, ubuntu-18.04]
python-version: [3.7, 3.8, 3.9, "3.10"]
os: [macos-latest, ubuntu-latest]
python-version: [3.8, 3.9, "3.10", "3.11", "3.12"]

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pythonpublish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools wheel twine
pip install setuptools wheel twine pyyaml
- name: Build and publish
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
Expand Down
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.3.0
rev: v4.4.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: 22.6.0
rev: 23.1.0
hooks:
- id: black
107 changes: 95 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,32 @@

# Reproschema Python library and Command Line Interface (CLI)


### Installation
## Installation

reproschema requires Python 3.7+.

```
pip install reproschema
```

### Developer installation

Install repo in developer mode:

```
git clone https://github.com/ReproNim/reproschema-py.git
cd reproschema-py
pip install -e .[dev]
```

It is also useful to install pre-commit, which takes care of styling when
committing code. When pre-commit is used you may have to run git commit twice,
since pre-commit may make additional changes to your code for styling and will
not commit these changes by default:

```
pre-commit install
```
## CLI usage

This package installs `reproschema` a CLI.
Expand All @@ -34,25 +51,91 @@ Options:
Commands:
convert
create
redcap2reproschema Convert REDCap CSV files to Reproschema format.
reproschema2redcap Convert reproschema protocol to REDCap CSV format.
serve
validate
```

## Developer installation
## `reproschema2redcap` Usage

Install repo in developer mode:
### Command-Line Usage

You can use this feature directly from the command line. To convert ReproSchema protocol to REDCap CSV format, use the following command

```
git clone https://github.com/ReproNim/reproschema-py.git
cd reproschema-py
pip install -e .[dev]
reproschema reproschema2redcap <input_dir_path> <output_csv_filename>
```

It is also useful to install pre-commit, which takes care of styling when
committing code. When pre-commit is used you may have to run git commit twice,
since pre-commit may make additional changes to your code for styling and will
not commit these changes by default:
- `<input_dir_path>`: The path to the root folder of a protocol. For example, to convert the reproschema-demo-protocol provided by ReproNim, you can use the following commands:
```bash
git clone https://github.com/ReproNim/reproschema-demo-protocol.git
cd reproschema-demo-protocol
pwd
```
In this case, the output from `pwd` (which shows your current directory path)should be your `<input_dir_path>`.
- `<output_csv_filename>`: The name of the output CSV file where the converted data will be saved.

### Python Function Usage

You can also use the `reproschema2redcap` function from the `reproschema-py` package in your Python code.

```python
from reproschema import reproschema2redcap

input_dir_path = "path-to/reproschema-demo-protocol"
output_csv_filename = "output.csv"

reproschema2redcap(input_dir_path, output_csv_filename)
```
pre-commit install

## `redcap2reproschema` Usage
The `redcap2reproschema` function is designed to process a given REDCap CSV file and YAML configuration to generate the output in the reproschema format.

### Prerequisites
Before the conversion, ensure you have the following:

**YAML Configuration File**:
- Download [templates/redcap2rs.yaml](templates/redcap2rs.yaml) and fill it out with your protocol details.

### YAML File Configuration
In the `templates/redcap2rs.yaml` file, provide the following information:

- **protocol_name**: This is a unique identifier for your protocol. Use underscores for spaces and avoid special characters.
- **protocol_display_name**: The name that will appear in the application.
- **protocol_description**: A brief description of your protocol.

Example:
```yaml
protocol_name: "My_Protocol"
protocol_display_name: "Assessment Protocol"
protocol_description: "This protocol is for assessing cognitive skills."
```
### Command-Line Usage

The `redcap2reproschema`` function has been integrated into a CLI tool, use the following command:
```bash
reproschema redcap2reproschema path/to/your_redcap_data_dic.csv path/to/your_redcap2rs.yaml
```

### Python Function Usage

You can also use the `redcap2reproschema` function from the `reproschema-py` package in your Python code.

```python
from reproschema import redcap2reproschema

csv_path = "path-to/your_redcap_data_dic.csv"
yaml_path = "path-to/your_redcap2rs.yaml"

reproschema2redcap(input_dir_path, output_csv_filename)
```

After configuring the YAML file:

1. Run the Python script with the paths to your CSV file and the YAML file as arguments.
2. Command Format: `python script_name.py path/to/your_redcap_data_dic.csv path/to/your_redcap2rs.yaml`

### Notes
1. The script requires an active internet connection to access the GitHub repository.
2. Make sure you use `git add`, `git commit`, `git push` properly afterwards to maintain a good version control for your converted data.
4 changes: 4 additions & 0 deletions reproschema/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,7 @@ def set_logger_level(lgr, level):
lgr.warning(
"Failed to check for a more recent version available with etelemetry: %s", exc
)

from . import _version

__version__ = _version.get_versions()["version"]