Skip to content

Commit

Permalink
Adds logging to diagnose problem
Browse files Browse the repository at this point in the history
  • Loading branch information
Kelli Scheuble committed Jun 16, 2020
1 parent 07f4fc7 commit 1751952
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 29 deletions.
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -113,4 +113,8 @@ venv.bak/
.dmypy.json
dmypy.json
# Pyre type checker
.pyre/
.pyre/
# Elastic Beanstalk Files
.elasticbeanstalk/*
!.elasticbeanstalk/*.cfg.yml
!.elasticbeanstalk/*.global.yml
47 changes: 22 additions & 25 deletions Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 14 additions & 2 deletions src/app/extract.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import logging
import requests
import pandas as pd
from flatten_dict import flatten

import os

logging.basicConfig(level=logging.INFO, format="%(asctime)s:%(name)s:%(message)s")

app_id = os.environ["APP_ID"]
api_key = os.environ["API_KEY"]

Expand Down Expand Up @@ -51,7 +54,10 @@ def adzuna():
appended_results = list()

for title in main_titles:


logging.info("="*20)
logging.info(f"Adzuna request for {title}:")

request = requests.get(
"https://api.adzuna.com/v1/api/jobs/us/search/1",
params={
Expand All @@ -65,6 +71,8 @@ def adzuna():

result = request.json()

logging.info(f" Number of jobs pulled :{len(result['results'])}")

# flatten nested objects returned by API by looping over each job
flattened_results = [
flatten(job, reducer="underscore") for job in result["results"]
Expand Down Expand Up @@ -158,6 +166,8 @@ def jobsearcher():
each individual job title search.
"""

logging.info(f"JobSearcher request for {title}:")

x = 1
offset = 0
while x > 0:
Expand All @@ -175,7 +185,9 @@ def jobsearcher():

offset += 100
result = request.json()


logging.info(f"{result}")

x = len(result["data"])
# flatten nested objects
flattened_results = [
Expand Down
4 changes: 3 additions & 1 deletion src/app/load.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ def gendata(df):
"company": row["company"],
"description": row["description"],
"publication_date": row["publication_date"],
"inserted_date": row["inserted_date"],
"location_city": row["city"],
"location_state": row["state"],
"location_point": f"{row['latitude']},{row['longitude']}",
Expand All @@ -53,4 +54,5 @@ def gendata(df):

def query(df):

print(bulk(es, gendata(df)))
print(df)
#print(bulk(es, gendata(df)))

0 comments on commit 1751952

Please sign in to comment.