"""Entrypoint.""" import datetime from dotenv import load_dotenv load_dotenv() def main(): from src import data test_data = data.load_data() try: run_reports(test_data) finally: data.dump_data(test_data) def run_reports(test_data): from src import api client = api.IrcamAPI() for index, _ in enumerate(test_data): if test_data[index]['run_at']: continue if not test_data[index]['file_id']: test_data[index]['file_id'] = client.create_storage_file_id() if not test_data[index]['is_uploaded']: client.upload_media(test_data[index]['file_id'], test_data[index]['filepath']) test_data[index]['is_uploaded'] = True if not test_data[index]['ias_id']: test_data[index]['ias_id'] = client.get_ias_id_from_file_id(test_data[index]['file_id']) if not test_data[index]['job_id']: test_data[index]['job_id'] = client.create_ai_detector_job_id([test_data[index]['ias_id']]) if not test_data[index]['result']: test_data[index]['result'] = client.get_report(test_data[index]['job_id']) if not test_data[index]['run_at']: test_data[index]['run_at'] = str(datetime.datetime.now(datetime.UTC)) if __name__ == '__main__': main()