Skip to content

Commit

Permalink
print stuff for testing help
Browse files Browse the repository at this point in the history
  • Loading branch information
atvaccaro committed Sep 21, 2022
1 parent dd218eb commit 1228708
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 4 deletions.
1 change: 1 addition & 0 deletions airflow/dags/check_feed_aggregators/check_aggregators.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ arguments:
- "/secrets/agencies-data/data_agencies.yaml"
- "--output={{get_bucket()}}/feed_aggregator_checks/dt={{execution_date.to_date_string()}}/checks.jsonl"
- "--output-format=JSONL"
- "--progress"

is_delete_operator_pod: true
get_logs: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import urllib.request
from collections import OrderedDict

import typer
import yaml

from .transitfeeds import get_transitfeeds_urls
Expand Down Expand Up @@ -35,6 +36,7 @@ def check_feeds(yml_file=None, csv_file=None, url=None, progress=False):
"transitland": {"status": "missing"},
}
elif csv_file:
typer.echo(f"reading urls from {csv_file}")
with open(csv_file, "r") as f:
urls = f.read().strip().splitlines()
for url in urls:
Expand All @@ -44,6 +46,7 @@ def check_feeds(yml_file=None, csv_file=None, url=None, progress=False):
"transitland": {"status": "missing"},
}
else:
typer.echo(f"reading urls from {yml_file}")
with open(yml_file, "r") as f:
agencies_obj = yaml.load(f, Loader=yaml.SafeLoader)
for agency in agencies_obj.values():
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from urllib.error import HTTPError

import typer
from bs4 import BeautifulSoup
from tqdm import tqdm

Expand All @@ -18,7 +19,7 @@ def resolve_url(url):


def get_transitfeeds_urls(progress=False):
print("fetching transit feeds URLs")
typer.echo("fetching transit feeds URLs")

page_urls = []
provider_urls = []
Expand Down Expand Up @@ -49,7 +50,7 @@ def get_transitfeeds_urls(progress=False):
try:
html = curl_cached(feed_url)
except HTTPError:
print("failed to fetch:", feed_url)
typer.echo(f"failed to fetch: {feed_url}")
continue

soup = BeautifulSoup(html, "html.parser")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import json
from typing import List, Tuple

import typer
from tqdm import tqdm

from .cache import curl_cached
Expand Down Expand Up @@ -33,7 +34,7 @@ def get_feeds(after=None):


def get_transitland_urls(progress=False) -> List[Tuple[str, str]]:
print("fetching transitland URLs")
typer.echo("fetching transitland URLs")
if not API_KEY:
raise RuntimeError("TRANSITLAND_API_KEY must be set")

Expand All @@ -52,5 +53,5 @@ def get_transitland_urls(progress=False) -> List[Tuple[str, str]]:
if not after:
break
else:
print("WARNING: hit loop limit for transitland")
typer.echo("WARNING: hit loop limit for transitland")
return urls

0 comments on commit 1228708

Please sign in to comment.