Skip to content

Commit 1ff22d6

Browse files
committed
Merge pull request #69 from johnb30/master
Allow date string as arg to pipeline.main()
2 parents c438035 + a1ad52a commit 1ff22d6

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

pipeline.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import sys
44
import logging
55
import datetime
6+
import dateutil
67
import uploader
78
import utilities
89
import formatter
@@ -13,7 +14,8 @@
1314
from petrarch import petrarch
1415

1516

16-
def main(file_details, server_details, logger_file=None, run_filter=None):
17+
def main(file_details, server_details, logger_file=None, run_filter=None,
18+
run_date=None):
1719
"""
1820
Main function to run all the things.
1921
@@ -35,6 +37,11 @@ def main(file_details, server_details, logger_file=None, run_filter=None):
3537
run_filter: String.
3638
Whether to run the ``oneaday_formatter``. Takes True or False
3739
(strings) as values.
40+
41+
run_date: String.
42+
Date of the format YYYYMMDD. The pipeline will run using this
43+
date. If not specified the pipeline will run with
44+
``current_date`` minus one day.
3845
"""
3946
if logger_file:
4047
utilities.init_logger(logger_file)
@@ -45,9 +52,11 @@ def main(file_details, server_details, logger_file=None, run_filter=None):
4552

4653
print('\nPHOX.pipeline run:', datetime.datetime.utcnow())
4754

48-
if len(sys.argv) > 1:
49-
date_string = sys.argv[1]
50-
process_date = datetime.datetime.utcnow() - datetime.timedelta(days=1)
55+
if run_date:
56+
process_date = dateutil.parser.parse(run_date)
57+
date_string = '{:02d}{:02d}{:02d}'.format(process_date.year,
58+
process_date.month,
59+
process_date.day)
5160
logger.info('Date string: {}'.format(date_string))
5261
print('Date string:', date_string)
5362
else:

0 commit comments

Comments
 (0)