Skip to content
This repository has been archived by the owner on Jan 23, 2024. It is now read-only.

Commit

Permalink
Handle no job list gracefully
Browse files Browse the repository at this point in the history
  • Loading branch information
dpriskorn committed Feb 9, 2022
1 parent 91392bb commit 5bda59a
Showing 1 changed file with 24 additions and 22 deletions.
46 changes: 24 additions & 22 deletions src/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,28 +92,30 @@ def export_jobs_to_dataframe():
logger = logging.getLogger(__name__)
logger.info("Exporting jobs to DataFrame. All jobs are appended to one frame")
jobs = parse_job_pickle()
number_of_jobs = len(jobs)
if jobs is not None and number_of_jobs > 0:
logger.info(f"Found {number_of_jobs} jobs")
df = pd.DataFrame()
count = 1
for job in jobs:
count += 1
logger.info(f"Working on job {count}/{number_of_jobs}")
job_df = pd.DataFrame()
for item in job.items.list:
job_df = job_df.append(pd.DataFrame(data=[dict(
qid=item.id,
label=item.label,
description=item.description
)]))
df = df.append(job_df)
logger.debug(f"Added {len(job.items.list)} items to the dataframe")
logger.debug(f"Exporting {len(df)} rows to pickle")
pickle_filename = "dataframe.pkl.gz"
df.to_pickle(pickle_filename)
console.print(f"Wrote to {pickle_filename} in the current directory")

if jobs is not None:
number_of_jobs = len(jobs)
if jobs is not None and number_of_jobs > 0:
logger.info(f"Found {number_of_jobs} jobs")
df = pd.DataFrame()
count = 1
for job in jobs:
count += 1
logger.info(f"Working on job {count}/{number_of_jobs}")
job_df = pd.DataFrame()
for item in job.items.list:
job_df = job_df.append(pd.DataFrame(data=[dict(
qid=item.id,
label=item.label,
description=item.description
)]))
df = df.append(job_df)
logger.debug(f"Added {len(job.items.list)} items to the dataframe")
logger.debug(f"Exporting {len(df)} rows to pickle")
pickle_filename = "dataframe.pkl.gz"
df.to_pickle(pickle_filename)
console.print(f"Wrote to {pickle_filename} in the current directory")
else:
console.print("No jobs found. Create a job list first by using '--prepare-jobs'")

def export_jobs_to_quickstatements():
logger = logging.getLogger(__name__)
Expand Down

0 comments on commit 5bda59a

Please sign in to comment.