Permalink
Browse files

Merge branch 'master' into netcdf

  • Loading branch information...
jvdzwaan committed Oct 9, 2018
2 parents 3946f20 + a7d1fd1 commit d2b3e1ac5e7658520bc07800ff544d005b5414fd
@@ -0,0 +1,23 @@
# Database Schema
| Field | Description | Example |
| ----- | ----------- | ------- |
| `unique_id` | | ff129fee-c0d9-47cc-b0a9-997a530230a8 |
| `author` | Username of the one running the script | |
| `description` | Currently not used? | |
| `inputs` | List of input files (can be empty) | |
| `outputs` | List of output files (can be empty) | |
| `script` | Path to the script that was run | |
| `command` | Path to the python executable that was used to run the script | `/usr/bin/python2.7` |
| `environment` | Information about the environment in which the script was run (including Python version) | Linux-4.15.0-29-generic-x86_64-with-debian-stretch-sid python 2.7.15 -Anaconda, Inc.- (default, May 1 2018, 23:32:55) |
| `date` | Date and time the script was run (in UTC) | |
| `command_args` | Command line arguments of the script (can be empty) | |
| `warnings` | Warnings issued during execution of the script (if any) | |
| `exception` | Exception raised during execution of the script (if any) | |
| `libraries` | Names and versions of patched libraries used in this script | |
| `notes` | Notes added by the user by running `recipy annotate` or in the gui | |
| `custom_values` | Values logged explicitly in the script by calling `recipy.log_values({'name': 'value'})` | |
| `gitrepo`/`svnrepo` | | |
| `gitcommit`/`svncommit` | Current git/svn commit | |
| `gitorigin` | | |
| `diff` | | |
@@ -2,11 +2,19 @@
script: run_python.py
libraries: [ ]
test_cases:
- arguments: [ open ]
- arguments: [ open_write_args ]
outputs: [ out.txt ]
#skip: "recipy raises 'KeyError: 'mode'' under Python 3 and 'ValueError: I/O operation on closed file' under Python 2 logging this function"
- arguments: [ open_write_kwargs ]
outputs: [ out.txt ]
skip: "recipy raises 'KeyError: 'mode'' under Python 3 and 'ValueError: I/O operation on closed file' under Python 2 logging this function"
- arguments: [ warn ]
- arguments: [ error ]
- arguments: [ open_read_args ]
inputs: [ in.txt ]
- arguments: [ open_read_kwargs ]
inputs: [ in.txt ]
- arguments: [ open_default ]
inputs: [ in.txt ]
---
script: run_numpy_as_opaque.py
libraries: [ numpy ]
@@ -0,0 +1 @@
This is a text input file.
@@ -32,13 +32,14 @@ def __init__(self):
Constructor.
"""
Base.__init__(self)
self.data_dir = os.path.join(self.current_dir, "data", "python")
def open(self):
def open_write_args(self):
"""
Use recipy.open to save a file out.txt.
"""
file_name = os.path.join(self.current_dir, "out.txt")
with recipy.open('out.txt', 'w') as f:
with recipy.open(file_name, 'w') as f:
f.write("This is a test")
os.remove(file_name)
@@ -55,6 +56,38 @@ def error(self):
with pytest.raises(ValueError):
raise ValueError('This is an error.')
def open_write_kwargs(self):
"""
Use recipy.open to save a file out.txt.
"""
file_name = os.path.join(self.current_dir, "out.txt")
with recipy.open(file_name, mode='w') as f:
f.write("This is a test")
os.remove(file_name)
def open_read_args(self):
"""
Use recipy.open to save a file out.txt.
"""
file_name = os.path.join(self.data_dir, "in.txt")
with recipy.open(file_name, 'r') as f:
pass
def open_read_kwargs(self):
"""
Use recipy.open to save a file out.txt.
"""
file_name = os.path.join(self.data_dir, "in.txt")
with recipy.open(file_name, mode='r') as f:
pass
def open_default(self):
"""
Use recipy.open to save a file out.txt.
"""
file_name = os.path.join(self.data_dir, "in.txt")
with recipy.open(file_name) as f:
pass
if __name__ == "__main__":
PythonSample().invoke(sys.argv)
@@ -16,13 +16,10 @@ def open(*args, **kwargs):
If python 2 is used, and an `encoding` parameter is passed to this
function, `codecs` is used to open the file with proper encoding.
"""
if six.PY3:
mode = kwargs['mode']
else:
try:
mode = args[1]
except:
mode = 'r'
try:
mode = args[1]
except IndexError:
mode = kwargs.get('mode', 'r')
# open file for reading?
for c in 'r+':
@@ -39,8 +39,13 @@ def listsearch(query, item):
"""
fh = ''
if not isinstance(item, six.string_types):
fh = item[1]
item = item[0]
try:
fh = item[1]
item = item[0]
except IndexError:
item = ''
return bool(re.search(query, item) or
re.search(query, fh))
if fh is None:
fh = ''
return bool(re.search(query, item) or re.search(query, fh))
@@ -36,3 +36,21 @@ def test_listsearch_list_of_lists_no_match(item):
msg = 'listsearch({}, {}) does not return false'.format(q, item)
assert not listsearch(q, item), msg
def test_listsearch_empty_item():
item = []
q = 'test'
msg = 'listsearch fails when item=[]'
assert not listsearch(q, item), msg
def test_listsearch_hash_is_none():
item = [u'test.csv', None]
q = 'test'
msg = 'listsearch fails when hash is None'
assert listsearch(q, item), msg

0 comments on commit d2b3e1a

Please sign in to comment.