File tree Expand file tree Collapse file tree 2 files changed +26
-1
lines changed
Expand file tree Collapse file tree 2 files changed +26
-1
lines changed Original file line number Diff line number Diff line change @@ -8,6 +8,8 @@ __pycache__/
88# Ignore editor configuration
99.idea /
1010.vscode /
11+ * .sublime-project
12+ * .sublime-workspace
1113
1214# Ignore other detritus
1315* .log
@@ -16,3 +18,6 @@ __pycache__/
1618coverage.xml
1719issues.json
1820htmlcov /
21+
22+ errors.txt
23+ info.txt
Original file line number Diff line number Diff line change @@ -773,11 +773,31 @@ def serialize_bq(bq_dict, filename='bq.json'):
773773 """Write metadata collected for validation to json file
774774 BigQuery requires newline delimited json objects
775775 """
776- data = json .dumps (bq_dict )
776+ bq_dict_copy = bq_dict .copy ()
777+ if ('organism_age' in bq_dict and 'organism_age__unit_label' in bq_dict ):
778+ bq_dict_copy ['organism_age__seconds' ] = calculate_organism_age_in_seconds (bq_dict ['organism_age' ], bq_dict ['organism_age__unit_label' ])
779+
780+ data = json .dumps (bq_dict_copy )
777781 with open (filename , 'a' ) as jsonfile :
778782 jsonfile .write (data + '\n ' )
779783
780784
785+ def calculate_organism_age_in_seconds (organism_age , organism_age_unit_label ):
786+ multipliers = {
787+ 'microsecond' : 0.000001 ,
788+ 'millisecond' : 0.001 ,
789+ 'second' : 1 ,
790+ 'minute' : 60 ,
791+ 'hour' : 3600 ,
792+ 'day' : 86400 ,
793+ 'week' : 604800 ,
794+ 'month' : 2626560 , #(day * 30.4 to fuzzy-account for different months)
795+ 'year' : 31557600 # (day * 365.25 to fuzzy-account for leap-years)
796+ }
797+ multiplier = multipliers [organism_age_unit_label ]
798+ return organism_age * multiplier
799+
800+
781801def serialize_issues (metadata ):
782802 """Write collected issues to json file
783803 """
You can’t perform that action at this time.
0 commit comments