Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix encumbrance script configs #1481

Merged
merged 3 commits into from
Dec 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions libsys_airflow/dags/folio_finance/lane_fix_encumbrances.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"depends_on_past": False,
"email_on_failure": True,
"email_on_retry": False,
"retries": 1,
"retries": 0,
"retry_delay": timedelta(minutes=1),
}

Expand Down Expand Up @@ -64,7 +64,7 @@
send_logs = PythonOperator(
task_id="email_fix_encumbrances_log",
python_callable=email_log,
trigger_rule='always',
trigger_rule='all_done',
op_kwargs={
"log_file": "{{ ti.xcom_pull('run_fix_encumbrances_script') }}",
"fy_code": FY_CODE,
Expand Down
4 changes: 2 additions & 2 deletions libsys_airflow/dags/folio_finance/law_fix_encumbrances.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"depends_on_past": False,
"email_on_failure": True,
"email_on_retry": False,
"retries": 1,
"retries": 0,
"retry_delay": timedelta(minutes=1),
}

Expand Down Expand Up @@ -63,7 +63,7 @@
send_logs = PythonOperator(
task_id="email_fix_encumbrances_log",
python_callable=email_log,
trigger_rule='always',
trigger_rule='all_done',
op_kwargs={
"log_file": "{{ ti.xcom_pull('run_fix_encumbrances_script') }}",
"fy_code": FY_CODE,
Expand Down
4 changes: 2 additions & 2 deletions libsys_airflow/dags/folio_finance/sul_fix_encumbrances.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"depends_on_past": False,
"email_on_failure": True,
"email_on_retry": False,
"retries": 1,
"retries": 0,
"retry_delay": timedelta(minutes=1),
}

Expand Down Expand Up @@ -64,7 +64,7 @@
send_logs = PythonOperator(
task_id="email_fix_encumbrances_log",
python_callable=email_log,
trigger_rule='always',
trigger_rule='all_done',
op_kwargs={
"log_file": "{{ ti.xcom_pull('run_fix_encumbrances_script') }}",
"fy_code": FY_CODE,
Expand Down
30 changes: 15 additions & 15 deletions libsys_airflow/plugins/folio/encumbrances/fix_encumbrances.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def login(tenant, username, password):
except Exception as err:
print('Error during login:', err)
logger.error('Error during login:', err)
raise SystemExit(1)
raise Exception("Exiting Fix Encumbrances script.")


async def get_request_without_query(url: str) -> dict:
Expand All @@ -70,11 +70,11 @@ async def get_request_without_query(url: str) -> dict:
else:
print(f'Error getting record with url {url} : \n{resp.text} ')
logger.error(f'Error getting record with url {url} : \n{resp.text} ')
raise SystemExit(1)
raise Exception("Exiting Fix Encumbrances script.")
except Exception as err:
print(f'Error getting record with url {url} : {err=}')
logger.error(f'Error getting record with url {url} : {err=}')
raise SystemExit(1)
raise Exception("Exiting Fix Encumbrances script.")


async def get_request(url: str, query: str) -> dict:
Expand All @@ -90,11 +90,11 @@ async def get_request(url: str, query: str) -> dict:
else:
print(f'Error getting records by {url} ?query= "{query}": \n{resp.text} ')
logger.error(f'Error getting records by {url} ?query= "{query}": \n{resp.text} ')
raise SystemExit(1)
raise Exception("Exiting Fix Encumbrances script.")
except Exception as err:
print(f'Error getting records by {url}?query={query}: {err=}')
logger.error(f'Error getting records by {url}?query={query}: {err=}')
raise SystemExit(1)
raise Exception("Exiting Fix Encumbrances script.")


async def put_request(url: str, data):
Expand All @@ -108,12 +108,12 @@ async def put_request(url: str, data):
return
print(f'Error updating record {url} "{data}": {resp.text}')
logger.error(f'Error updating record {url} "{data}": {resp.text}')
raise SystemExit(1)
raise Exception("Exiting Fix Encumbrances script.")

except Exception as err:
print(f'Error updating record {url} "{data}": {err=}')
logger.error(f'Error updating record {url} "{data}": {err=}')
raise SystemExit(1)
raise Exception("Exiting Fix Encumbrances script.")


async def delete_request(url: str):
Expand All @@ -125,12 +125,12 @@ async def delete_request(url: str):
return
print(f'Error deleting record {url}: {resp.text}')
logger.error(f'Error deleting record {url}: {resp.text}')
raise SystemExit(1)
raise Exception("Exiting Fix Encumbrances script.")

except Exception as err:
print(f'Error deleting record {url}: {err=}')
logger.error(f'Error deleting record {url}: {err=}')
raise SystemExit(1)
raise Exception("Exiting Fix Encumbrances script.")


def get_fiscal_years_by_query(query) -> dict:
Expand All @@ -145,7 +145,7 @@ def get_fiscal_years_by_query(query) -> dict:
except Exception as err:
print(f'Error getting fiscal years with query "{query}": {err}')
logger.error(f'Error getting fiscal years with query "{query}": {err}')
raise SystemExit(1)
raise Exception("Exiting Fix Encumbrances script.")


def get_by_chunks(url, query, key) -> list:
Expand Down Expand Up @@ -185,7 +185,7 @@ def get_order_ids_by_query(query) -> list:
except Exception as err:
print(f'Error getting order ids with query "{query}": {err}')
logger.error(f'Error getting order ids with query "{query}": {err}')
raise SystemExit(1)
raise Exception("Exiting Fix Encumbrances script.")
return ids


Expand Down Expand Up @@ -213,7 +213,7 @@ def get_fiscal_year(fiscal_year_code) -> dict:
if len(fiscal_years) == 0:
print(f'Could not find fiscal year "{fiscal_year_code}".')
logger.error(f'Could not find fiscal year "{fiscal_year_code}".')
raise SystemExit(1)
raise Exception("Exiting Fix Encumbrances script.")
return fiscal_years[0]


Expand Down Expand Up @@ -267,7 +267,7 @@ async def get_budget_by_fund_id(fund_id, fiscal_year_id) -> dict:
logger.error(
f'Could not find budget for fund "{fund_id}" and fiscal year "{fiscal_year_id}".'
)
raise SystemExit(1)
raise Exception("Exiting Fix Encumbrances script.")
return budgets[0]


Expand Down Expand Up @@ -645,7 +645,7 @@ async def fix_order_status_and_release_encumbrances(order_id, encumbrances):
logger.error(
f'Error when fixing order status in encumbrances for order {order_id}:', err
)
raise SystemExit(1)
raise Exception("Exiting Fix Encumbrances script.")


async def fix_order_encumbrances_order_status(order_id, encumbrances):
Expand All @@ -672,7 +672,7 @@ async def fix_order_encumbrances_order_status(order_id, encumbrances):
logger.error(
f'Error when fixing order status in encumbrances for order {order_id}:', err
)
raise SystemExit(1)
raise Exception("Exiting Fix Encumbrances script.")


async def fix_encumbrance_order_status_for_closed_order(
Expand Down
Loading