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

merge from CTDS #14

Merged
merged 3 commits into from
May 6, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ fuzzywuzzy==0.6.1
gen3authz==0.2.1
graphene==2.0.1
jsonschema==3.2
lxml==4.4.2
lxml==4.6.3
pbr==2.0.0
psycopg2==2.8.4
python-keystoneclient==1.8.1
PyYAML==5.1
PyYAML==5.4
requests==2.22.0
setuptools==40.3.0
six==1.12.0
Expand All @@ -33,6 +33,6 @@ cdiserrors==0.1.2
cdislogging==1.0.0
git+https://git@github.com/NCI-GDC/cdisutils.git@f54e393c89939b2200dfae45c6235cbe2bae1206#egg=cdisutils
gen3dictionary==2.0.1
gen3datamodel==3.0.2
gen3datamodel==3.0.3
git+https://git@github.com/uc-cdis/indexclient.git@2.0.0#egg=indexclient
git+https://git@github.com/uc-cdis/storage-client.git@1.0.0#egg=storageclient
11 changes: 9 additions & 2 deletions sheepdog/utils/transforms/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,18 @@ def parse_bool_from_string(value):
def parse_list_from_string(value):
"""
Handle array fields by converting them to a list.
Try to cast to float to handle arrays of numbers.

Example:
1,2,3 -> ['1','2','3']
a,b,c -> ['a','b','c']
1,2,3 -> [1,2,3]
"""
return [x.strip() for x in value.split(",")]
items = [x.strip() for x in value.split(",")]
try:
items = [float(x) for x in items]
except ValueError:
pass # not an array of numbers
return items


def set_row_type(row):
Expand Down
4 changes: 2 additions & 2 deletions sheepdog/utils/transforms/graph_to_doc.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,13 +153,13 @@ def list_to_comma_string(val, file_format):
"""

if val is None:
""" If a field is empty we must replace it with an empty string for tsv/csv exports and leave it as None for json exports """
"""If a field is empty we must replace it with an empty string for tsv/csv exports and leave it as None for json exports"""
if file_format == "json":
return val
return ""

if isinstance(val, list):
val = ",".join(val)
val = ",".join((str(x) for x in val))
return val


Expand Down