From 7c024269e90d499da292ad7424bd8ed363c51987 Mon Sep 17 00:00:00 2001 From: stefancoe Date: Fri, 3 Feb 2023 17:43:30 -0800 Subject: [PATCH] Release 0.1.4 --- combine_gtfs_feeds/cli/__init__.py | 5 ++++- combine_gtfs_feeds/cli/gtfs_schema.py | 12 +++++----- combine_gtfs_feeds/cli/run.py | 32 ++++++++++++++++++--------- requirements.txt | 9 +++++--- setup.py | 3 ++- 5 files changed, 39 insertions(+), 22 deletions(-) diff --git a/combine_gtfs_feeds/cli/__init__.py b/combine_gtfs_feeds/cli/__init__.py index 6089ed3..d2e4f7c 100644 --- a/combine_gtfs_feeds/cli/__init__.py +++ b/combine_gtfs_feeds/cli/__init__.py @@ -1,3 +1,6 @@ from .cli import CLI -from . import run from .gtfs_schema import GTFS_Schema +from . import run + + + diff --git a/combine_gtfs_feeds/cli/gtfs_schema.py b/combine_gtfs_feeds/cli/gtfs_schema.py index 9e83464..1846c6a 100644 --- a/combine_gtfs_feeds/cli/gtfs_schema.py +++ b/combine_gtfs_feeds/cli/gtfs_schema.py @@ -88,12 +88,12 @@ class Stop_Times(pa.SchemaModel): drop_off_type: Optional[Series[pd.Int64Dtype]] = pa.Field( coerce=True, nullable=True, isin=[0, 1, 2, 3] ) - continuous_pickup: Optional[Series[pd.Int64Dtype]] = pa.Field( - coerce=True, nullable=True, isin=[0, 1, 2, 3] - ) - continuous_drop_off: Optional[Series[pd.Int64Dtype]] = pa.Field( - coerce=True, nullable=True, isin=[0, 1, 2, 3] - ) + # continuous_pickup: Optional[Series[pd.Int64Dtype]] = pa.Field( + # coerce=True, nullable=True, isin=[0, 1, 2, 3] + # ) + # continuous_drop_off: Optional[Series[pd.Int64Dtype]] = pa.Field( + # coerce=True, nullable=True, isin=[0, 1, 2, 3] + # ) shape_dist_traveled: Optional[Series[float64]] = pa.Field( coerce=True, nullable=True, ge=0 ) diff --git a/combine_gtfs_feeds/cli/run.py b/combine_gtfs_feeds/cli/run.py index 801d7fa..e1fd2a5 100644 --- a/combine_gtfs_feeds/cli/run.py +++ b/combine_gtfs_feeds/cli/run.py @@ -1,5 +1,9 @@ import combine_gtfs_feeds.cli.log_controller as log_controller -from gtfs_schema import GTFS_Schema +try: + from .gtfs_schema import GTFS_Schema +except: + from gtfs_schema import GTFS_Schema + import pandas as pd import numpy as np import os as os @@ -14,8 +18,9 @@ class Combined_GTFS(object): file_list = ["agency", "trips", "stop_times", "stops", "routes", "shapes"] - def __init__(self, df_dict): + def __init__(self, df_dict, output_dir): # self.agency_df = df_dict["agency"] + self.output_dir = output_dir self.agency_df = GTFS_Schema.Agency.validate(df_dict["agency"]) self.agency_df = self.agency_df[ [col for col in GTFS_Schema.agency_columns if col in self.agency_df.columns] @@ -65,8 +70,8 @@ def __init__(self, df_dict): ] ] - def export_feed(self, dir): - dir = Path(dir) + def export_feed(self): + dir = Path(self.output_dir) self.agency_df.to_csv(dir / "agency.txt", index=None) self.routes_df.to_csv(dir / "routes.txt", index=None) self.stops_df.to_csv(dir / "stops.txt", index=None) @@ -362,18 +367,21 @@ def run(args): a single feed. """ - logger = log_controller.setup_custom_logger("main_logger", args.output_dir) - logger.info("------------------combine_gtfs_feeds Started----------------") + #logger = log_controller.setup_custom_logger("main_logger", args.output_dir) + #logger.info("------------------combine_gtfs_feeds Started----------------") - feeds = combine(args.gtfs_dir, args.output_dir, args.service_date, logger) + feeds = combine(args.gtfs_dir, args.service_date, args.output_dir) - feeds.export_feed(args.output_dir) + feeds.export_feed() - logger.info("Finished running combine_gtfs_feeds") + #logger.info("Finished running combine_gtfs_feeds") # sys.exit() + print ("Finished running combine_gtfs_feeds") -def combine(gtfs_dir, output_dir, service_date, logger): +def combine(gtfs_dir, service_date, output_dir): + logger = log_controller.setup_custom_logger("main_logger", output_dir) + logger.info("------------------combine_gtfs_feeds Started----------------") output_loc = output_dir if not os.path.isdir(output_loc): @@ -540,7 +548,9 @@ def combine(gtfs_dir, output_dir, service_date, logger): df = pd.concat([df, feed_dict[feed][file_name]]) combined_feed_dict[file_name] = df - return Combined_GTFS(combined_feed_dict) + #logger.info("Finished running combine_gtfs_feeds") + + return Combined_GTFS(combined_feed_dict, output_dir) if __name__ == "__main__": diff --git a/requirements.txt b/requirements.txt index a5098a8..e4db720 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,6 @@ -pandas>=1.0.0 -numpy>=1.16.1 -PyYAML>=5.1 +numpy==1.24.1 +pandas==1.5.3 +pandera==0.13.4 +pydantic==1.9.0 +PyYAML==6.0 +setuptools==65.6.3 diff --git a/setup.py b/setup.py index e07098f..e5b5095 100644 --- a/setup.py +++ b/setup.py @@ -11,7 +11,7 @@ setup( name="combine_gtfs_feeds", - version="0.1.3", + version="0.1.4", author="psrc staff", author_email="scoe@psrc.org", url="https://github.com/psrc/combine_gtfs_feeds", @@ -20,6 +20,7 @@ long_description_content_type="text/markdown", license="MIT", packages=find_packages(), + python_requires='>3.6.1', entry_points={ "console_scripts": ["combine_gtfs_feeds = combine_gtfs_feeds.cli.main:main"] },