Skip to content
This repository was archived by the owner on Oct 12, 2023. It is now read-only.

Commit acfe003

Browse files
committed
Merge branch 'release/0.14.1'
2 parents 7e25a04 + 4e263e2 commit acfe003

12 files changed

Lines changed: 177 additions & 10 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
*.pyc
22
*.pyo
33
*.egg-info/
4+
.coveralls.yml
45
config-example/vagrant-data/redcap.zip
56
formData.xml
67
rawData.xml

.travis.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,15 @@ install:
77
- pip install requests
88
- pip install lxml
99
- pip install sftpserver
10+
- pip install coveralls
1011

1112
script: make test
1213

14+
after_success:
15+
- coveralls
16+
17+
1318
branches:
1419
only:
1520
- master
1621
- develop
17-
18-

CHANGELOG

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,43 @@
1+
2015-04-23 v0.14.1
2+
* Summary: PreProc and PostProc Hooks! RED-I has added the ability to hook scripts for post processing and preprocessing along with other minor fixes. These features now allow for the writing of filters and the emailing of log messages, for example, at the begining and end of a RED-I run.
3+
4+
* removed project-specific code from preproc.py (Nicholas Rejack)
5+
* removing project-specific preprocessing test file (Nicholas Rejack)
6+
* removed line from settings.ini. REDI-I runs out of the box without any preprocessors required (Nich
7+
* removing test-scenarios bash script (Nicholas Rejack)
8+
* removed scenario data files. These were for project-specific testing. (Nicholas Rejack)
9+
* removed non-informative comments in redi.py (Nicholas Rejack)
10+
* removed renamed config dir (Nicholas Rejack)
11+
* renaming config to previous config-example (Nicholas Rejack)
12+
* added scenario 9 to test scenarios. (Nicholas Rejack)
13+
* added scenario 7. bash script now shows test number. (Nicholas Rejack)
14+
* added scenario 6 (Nicholas Rejack)
15+
* updated test-scenarios with scenario 6 : (Nicholas Rejack)
16+
* Add Scenario 9 (Taeber Rapczak)
17+
* Correct the date of a result in Scenario 5 (Taeber Rapczak)
18+
* Add Scenario 6 (Taeber Rapczak)
19+
* Add 5 test scenarios and test-scenarios.bash (Taeber Rapczak)
20+
* Do not filter rows without a known "panel" (Taeber Rapczak)
21+
* Correct spelling error (Ruchi Vivek Desai)
22+
* Fix order of expected output in test_fetch_panels (Taeber Rapczak)
23+
* Fix the numbering (Ruchi Vivek Desai)
24+
* Add missing tags (Ruchi Vivek Desai)
25+
* Replace hard-coded fetch_panels() (Taeber Rapczak)
26+
* Renumber the steps (Ruchi Vivek Desai)
27+
* Fix indentation briken by commit id b8431f26ec459daf1cc1efe9ebf7c4583dacc572 (Ruchi Vivek Desai)
28+
* Fix indentation of Windows installation instructions (Ruchi Vivek Desai)
29+
* Add instructions for installing RED-I on Windows (Ruchi Vivek Desai)
30+
* Fix email address (Ruchi Vivek Desai)
31+
* Minor code cleanup (Taeber Rapczak)
32+
* Add more context for preprocessors to use (Taeber Rapczak)
33+
* Implement filter_old_labs() (Taeber Rapczak)
34+
* Implement filter_old_labs() (Taeber Rapczak)
35+
* Implement group_rows_by_panel (Taeber Rapczak)
36+
* fetch_consent_dates function now implemented and working. (Nicholas Rejack)
37+
* Resolve preproc import issue (Taeber Rapczak)
38+
* updated preproc.py. Only fails on NotImplementedError now. (Nicholas Rejack)
39+
* updated preproc.py to fix variable names when fetching consent date. (Nicholas Rejack)
40+
141
2015-04-09 v0.14.0
242
* Summary: RED-I has multiple functional and other improvements in this release: licensing has been added in each file. RED-I is now available from PyPI as 'redi'. Most importantly,
343
when multiple lab results come in on the same day, RED-I now takes the first lab of the day, unless it has a value of 'canceled'. RED-I also auto-resumes in the case of a network timeout. Reporting has been improved with more information.

Makefile

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,6 @@ help:
2424
test: tests
2525
tests: coverage
2626
[ ! -d config/rules ] || python -munittest discover config/rules
27-
rm -f .coverage
28-
rm -rf cover/
29-
rm -f coverage.xml nosetests.xml
3027

3128
coverage:
3229
ARCHFLAGS=$(ARCHFLAGS) python setup.py nosetests

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ RED-I Project
44
[![DOI](https://zenodo.org/badge/doi/10.5281/zenodo.10014.png ".")](http://dx.doi.org/10.5281/zenodo.10014)
55
[![Travis CI](https://api.travis-ci.org/ctsit/redi.svg?branch=master)](https://api.travis-ci.org/ctsit/redi.svg?branch=master)
66
[![Version](https://pypip.in/v/redi/badge.png)](https://pypip.in/v/redi/badge.png)
7+
[![Coverage Status Master](https://coveralls.io/repos/ctsit/redi/badge.svg?branch=master)](https://coveralls.io/r/ctsit/redi?branch=master)
8+
[![Coverage Status Develop](https://coveralls.io/repos/ctsit/redi/badge.svg?branch=develop)](https://coveralls.io/r/ctsit/redi?branch=develop)
79
[![Downloads](https://pypip.in/d/redi/badge.png)](https://pypip.in/d/redi/badge.png)
810

911

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# add post-processing rules here

config-example/preproc/preproc.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/usr/bin/env python
2+
3+
# Contributors:
4+
# Nicholas Rejack <nrejack@ufl.edu>
5+
# Kevin Hanson <hansonks@gmail.com>
6+
# Copyright (c) 2014-2015, University of Florida
7+
# All rights reserved.
8+
#
9+
# Distributed under the BSD 3-Clause License
10+
# For full text of the BSD 3-Clause License see http://opensource.org/licenses/BSD-3-Clause
11+
12+
# preprocessing rules go here.

config-example/settings.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@ emr_data_file = output.csv
154154
# This is an optional dictionary which indicates that
155155
# custom code needs to be run to validate the data
156156
rules = {}
157+
preprocessors = {}
157158

158159
# Set to "True" to include "rules" processing errors
159160
# Optional parameter

docs/about.rst

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,54 @@ To uninstall the application:
101101

102102
.. seealso:: http://pip.readthedocs.org/en/latest/reference/pip.html
103103

104+
Installing RED-I on Windows
105+
----------------------------
106+
107+
1. Install Python 2.7.x from: https://www.python.org/downloads/windows/
108+
2. Install a git client for Windows https://windows.github.com/
109+
3. Run Git Shell icon
110+
4. Clone the RED-I repository
111+
112+
.. raw:: html
113+
114+
<pre style="padding: 1em; background: #000; color: #fff; font: normal 1em Courier, Andale Mono">
115+
git clone https://github.com/ctsit/redi.git
116+
</pre>
117+
118+
5. Install Powershell 4 for Windows:
119+
http://www.microsoft.com/en-us/download/confirmation.aspx?id=40855
120+
6. Reboot
121+
7. Install Visual C++ 9:
122+
http://www.microsoft.com/en-us/download/details.aspx?id=44266
123+
8. Install SetupTools for Windows https://pypi.python.org/pypi/setuptools/12.2
124+
9. Launch PowerShell as administrator
125+
10. Run this command:
126+
127+
.. raw:: html
128+
129+
<pre style="padding: 1em; background: #000; color: #fff; font: normal 1em Courier, Andale Mono">
130+
(Invoke-WebRequest https://bootstrap.pypa.io/ez_setup.py).Content | python
131+
</pre>
132+
133+
11. Launch Git Shell icon
134+
12. In the redi/ directory, run:
135+
136+
.. raw:: html
137+
138+
<pre style="padding: 1em; background: #000; color: #fff; font: normal 1em Courier, Andale Mono">
139+
python setup.py bdist_egg
140+
cd c:\python27\scripts\
141+
.\easy_install.exe C:\Users\user1\Documents\code\redi\dist\redi_py-0.13.2-py2.7.egg
142+
</pre>
143+
144+
13. Add Python scripts directory to your system path by issuing the following command:
145+
146+
.. raw:: html
147+
148+
<pre style="padding: 1em; background: #000; color: #fff; font: normal 1em Courier, Andale Mono">
149+
set path=%PATH%;c:\python27\scripts
150+
</pre>
151+
104152

105153
How to Test RED-I with a Sample Project
106154
---------------------------------------
@@ -162,7 +210,7 @@ details about all arguments supported in the command line.
162210
How to Get Support
163211
------------------
164212

165-
If you need any help with using RED-I please email us at cts-it-red@ctsi.ufl.edu
213+
If you need any help with using RED-I please email us at ctsit@ctsi.ufl.edu
166214

167215
How to Contribute
168216
-----------------

redi/redi.py

Lines changed: 62 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
# Taeber Rapczak <taeber@ufl.edu>
1010
# Nicholas Rejack <nrejack@ufl.edu>
1111
# Josh Hanna <josh@hanna.io>
12+
# Kevin Hanson <hansonks@gmail.com>
1213
# Copyright (c) 2014-2015, University of Florida
1314
# All rights reserved.
1415
#
@@ -125,6 +126,9 @@ def main():
125126
126127
- write the Final ElementTree to EAV
127128
"""
129+
130+
131+
# TODO: UPDATE COMMENT HERE
128132
global _person_form_events_service
129133

130134
# obtaining command line arguments for path to configuration directory
@@ -191,11 +195,14 @@ def main():
191195
report_courier = report.ReportFileWriter(os.path.join(output_files,
192196
settings.report_file_path2), logger)
193197

198+
# This is the run that loads the data
194199
_run(config_file, configuration_directory, do_keep_gen_files, dry_run,
195200
get_emr_data, settings, output_files, db_path, redcap_client,
196201
report_courier, report_creator, args['--resume'],
197202
args['--skip-blanks'], args['--bulk-send-blanks'])
198203

204+
# TODO: post processing will go here
205+
199206

200207
def get_db_path(batch_info_database, database_path):
201208
if not os.path.exists(database_path):
@@ -297,7 +304,8 @@ def _run(config_file, configuration_directory, do_keep_gen_files, dry_run,
297304
settings.emr_sftp_server_private_key_pass,
298305
)
299306
GetEmrData.get_emr_data(configuration_directory, connection_details)
300-
307+
# load custom pre-processing filters
308+
pre_filters = load_preproc(settings.preprocessors, configuration_directory)
301309
# load custom post-processing rules
302310
rules = load_rules(settings.rules, configuration_directory)
303311

@@ -318,6 +326,10 @@ def _run(config_file, configuration_directory, do_keep_gen_files, dry_run,
318326
if not resume:
319327
_delete_last_runs_data(data_folder)
320328

329+
errors = run_preproc(pre_filters, settings)
330+
map(logger.warning, errors)
331+
# TODO: Add preproc errors to report
332+
321333
alert_summary, person_form_event_tree_with_data, rule_errors, \
322334
collection_date_summary_dict, bad_ids =\
323335
_create_person_form_event_tree_with_data(
@@ -1937,6 +1949,55 @@ def run_rules(data):
19371949
return loaded_rules
19381950

19391951

1952+
def load_preproc(preprocessors, root='./'):
1953+
"""
1954+
Copied and modified version of load_rules function.
1955+
TODO: fix load_rules and load_prerules for better parallelism
1956+
1957+
"""
1958+
if not preprocessors:
1959+
return {}
1960+
1961+
loaded = {}
1962+
1963+
for (preprocessor, path) in ast.literal_eval(preprocessors).iteritems():
1964+
module = None
1965+
if os.path.exists(path):
1966+
module = imp.load_source(preprocessor, path)
1967+
elif os.path.exists(os.path.join(root, path)):
1968+
module = imp.load_source(preprocessor, os.path.join(root, path))
1969+
1970+
assert module is not None
1971+
assert module.run_processing is not None
1972+
1973+
loaded[preprocessor] = module
1974+
1975+
logger.info("Loaded {} pre-processing script{}".format(
1976+
len(loaded), 's' if len(loaded) != 1 else 0))
1977+
return loaded
1978+
1979+
1980+
def run_preproc(preprocessors, settings):
1981+
# TODO figure out if this creates a sub process or not
1982+
# TODO need to check for program exe3cution otherwise give error
1983+
logger.info("Running preprocessing rules")
1984+
errors = []
1985+
1986+
for (preprocessor, module) in preprocessors.iteritems():
1987+
try:
1988+
module.run_processing(settings, redi=sys.modules[__name__],
1989+
logger=logging)
1990+
except Exception as e:
1991+
message_format = 'Error processing rule "{0}". {1}'
1992+
if not hasattr(e, 'errors'):
1993+
errors.append(message_format.format(preprocessor, e.message))
1994+
continue
1995+
for error in e.errors:
1996+
errors.append(message_format.format(preprocessor, error))
1997+
1998+
return errors
1999+
2000+
19402001
def run_rules(rules, person_form_event_tree_with_data):
19412002
errors = []
19422003

0 commit comments

Comments
 (0)