OSeMOSYS / otoole

OSeMOSYS Tools for Energy
https://otoole.readthedocs.io
MIT License
23 stars 17 forks source link

Fix error when converting from CSV #140

Closed trevorb1 closed 1 year ago

trevorb1 commented 1 year ago

Hi!

In this PR I address the issue presented in #138.

Logic

At the top of the ReadCSV.read(...) function, I change the logic from looping over all values in the config file to only looping over values that are tagged as param or set in the config file. I have added in tests for the ReadCSV.read(...) function as well.

Questions

I was struggling a bit with how to add tests for the ReadCSV.read(...) function. The issue is that ReadCSV.read(...) takes in a directory path that holds all the csvs. While I could extract out the location of the data/ folder in the zipped Simplicity fixture, that seemed like overkill because I would be testing all the *.csv files.

I instead created a simple config file in the TestReadCSV class, and included only the relevant csvs in a new fixture directory called tests/fixtures/data. The parameters and sets included in this directory are the minimum needed to test the functionality of the ReadCSV.read(...) function (I think!)

If this was totally wrong, so sorry! Please just let me know and maybe we can discuss how to correctly test this function :)

Thanks!

trevorb1 commented 1 year ago

Thanks for the feedback, @willu47!

I have updated this PR with the following:

Thanks!

trevorb1 commented 1 year ago

I am merging this with a couple extra additions not related to the actual issue:

  1. Seems that there was a recent addition to the isort package that broke with pre-commit. Following this thread on StackOverflow, I updated the isort version in .pre-commit-config.yaml
  2. This change is incompatible with Python 3.7, so I have removed checks for Python 3.7 in GitHub Actions and replaced it with Python version 3.11.
  3. This isort version change is causing issues with tests with the frictionless library. I can't figure out the reason why, but since these tests will be removed with PR #141, I have just commented them out for the time being. The errors that frictionless raise are stuff like:
    • TypeError: init() got an unexpected keyword argument 'onerror'
    • frictionless.exception.FrictionlessException: [error] schema is not set or inferred

But when I run the same commands outside of pytest, everything works fine. Anyways, since these tests are going to be removed soon, I am just going to move forward.