USEPA / standardizedinventories

Standardized Release and Waste Inventories
MIT License
25 stars 16 forks source link

Exception: error accessing table count #156

Closed bl-young closed 3 months ago

bl-young commented 3 months ago

___ test_generate_inventories[2020] ____

table = 'C_CONFIGURATION_LEVEL_INFO', report_year = '2020'

def get_row_count(table, report_year):
    """Return number of rows from API for specific table."""
    count_url = _config['enviro_url'] + table
    if report_year != '':
        count_url += f'/REPORTING_YEAR/=/{report_year}'
    count_url += '/COUNT'
    try:
        count_request = make_url_request(count_url)
        count_xml = minidom.parseString(count_request.text)
        table_count = count_xml.getElementsByTagName('TOTALQUERYRESULTS')
      table_count = int(table_count[0].firstChild.nodeValue)

E IndexError: list index out of range

stewi/GHGRP.py:127: IndexError

The above exception was the direct cause of the following exception:

year = 2020

@pytest.mark.parametrize("year", [2020])
@pytest.mark.inventory
def test_generate_inventories(year):
    for inventory in config()['databases']:
        try:
          generate_inventory(inventory, year)

tests/test_inventory_generation.py:30:


stewi/globals.py:302: in generate_inventory GHGRP.main(Option = 'A', Year = [year]) stewi/GHGRP.py:770: in main ghgrp1 = download_and_parse_subpart_tables(year, m) stewi/GHGRP.py:338: in download_and_parse_subpart_tables table_df = import_or_download_table(filepath, subpart_emissions_table, stewi/GHGRP.py:244: in import_or_download_table row_count = get_row_count(table, report_year=year)


table = 'C_CONFIGURATION_LEVEL_INFO', report_year = '2020'

def get_row_count(table, report_year):
    """Return number of rows from API for specific table."""
    count_url = _config['enviro_url'] + table
    if report_year != '':
        count_url += f'/REPORTING_YEAR/=/{report_year}'
    count_url += '/COUNT'
    try:
        count_request = make_url_request(count_url)
        count_xml = minidom.parseString(count_request.text)
        table_count = count_xml.getElementsByTagName('TOTALQUERYRESULTS')
        table_count = int(table_count[0].firstChild.nodeValue)
    except IndexError as e:
      raise Exception(f'error accessing table count for {table}') from e

E Exception: error accessing table count for C_CONFIGURATION_LEVEL_INFO

stewi/GHGRP.py:129: Exception