-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Refactor imports * Fix bad date reference (introduced error) * Add argparse with date and model options * Run if model selected or all * Move date funct. to utils * Create output dir on run_model to simplify logic * Add param to adjust logging level
- Loading branch information
1 parent
080a482
commit cfd8ccb
Showing
2 changed files
with
51 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import logging | ||
from datetime import datetime | ||
|
||
|
||
def validate_and_convert_date(date_str): | ||
""" | ||
Validates a date string in 'YYYY-MM-DD' format and converts it to a date object. | ||
""" | ||
try: | ||
dateobj = datetime.strptime(date_str, '%Y-%m-%d') | ||
return dateobj.date() | ||
except ValueError as e: | ||
logging.error(f"Invalid date format for '{date_str}', expected YYYY-MM-DD") | ||
raise ValueError(f"Invalid date format: {date_str}, expected YYYY-MM-DD") from e |