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

Commit

Permalink
jobs.py: get_validated_main_subjects_as_jobs(): Add logging.
Browse files Browse the repository at this point in the history
console.py: print_job_statistics(): Fix wrong logic.
  • Loading branch information
dpriskorn committed Jan 16, 2022
1 parent 9704911 commit 6ac76bd
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/helpers/console.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ def print_finished():
def print_job_statistics(jobs: List[BatchJob] = None):
if jobs is None:
raise ValueError("jobs was None")
if len(jobs) > 0:
if len(jobs) == 0:
console.print("The jobs list is empty")
else:
console.print(f"The jobs list now contain a total of {len(jobs)} "
Expand Down
6 changes: 5 additions & 1 deletion src/helpers/jobs.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from __future__ import annotations

import argparse
import logging
import random
from datetime import datetime
from typing import Union, List, TYPE_CHECKING
Expand Down Expand Up @@ -142,7 +143,7 @@ def get_validated_main_subjects_as_jobs(args: argparse.Namespace = None,
main_subjects: List[str] = None,
jobs: List[BatchJob] = None):
"""This function randomly picks a subject and present it for validation"""
# logger = logging.getLogger(__name__)
logger = logging.getLogger(__name__)
if jobs is None:
raise ValueError("jobs was None")
if not isinstance(jobs, List):
Expand All @@ -151,8 +152,10 @@ def get_validated_main_subjects_as_jobs(args: argparse.Namespace = None,
raise ValueError("args was None")
if main_subjects is None:
raise ValueError("main subjects was None")
jobs = jobs
subjects_not_picked_yet = main_subjects
while True:
# Check if we have any subjects left in the list
if len(subjects_not_picked_yet) > 0:
console.print(f"Picking a random main subject")
qid = random.choice(subjects_not_picked_yet)
Expand All @@ -164,6 +167,7 @@ def get_validated_main_subjects_as_jobs(args: argparse.Namespace = None,
confirmation=args.no_confirmation)
if job is not None:
jobs.append(job)
logger.debug(f"joblist now has {len(jobs)} jobs")
print_job_statistics(jobs=jobs)
if len(subjects_not_picked_yet) > 0:
if (
Expand Down

0 comments on commit 6ac76bd

Please sign in to comment.