diff --git a/.github/workflows/pytest.yml b/.github/workflows/pytest.yml new file mode 100644 index 0000000..95138d3 --- /dev/null +++ b/.github/workflows/pytest.yml @@ -0,0 +1,31 @@ +name: Run Pytest + +on: [push, pull_request] + +jobs: + test: + strategy: + matrix: + os: ["ubuntu-latest", "windows-latest", "macOS-latest"] + python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"] + runs-on: ${{ matrix.os }} + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -r requirements.txt + + - name: Run tests + env: + EIA_TOKEN: ${{ secrets.EIA_TOKEN }} + run: | + pytest tests/test_api.py \ No newline at end of file diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..3b152be --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,28 @@ +# Contributing to myeia +We love your input! We want to make contributing to this project as easy and transparent as possible, whether it's: + +- Reporting a bug +- Discussing the current state of the code +- Submitting a fix +- Proposing new features + +## Report bugs using Github's [issues](https://github.com/philsv/myeia/issues/) +We use GitHub issues to track public bugs. Report a bug by [opening a new issue](https://github.com/philsv/myeia/issues/new); it's that easy! + +Write bug reports with detail, background, and sample code if possible. **Great Bug Reports** tend to have: + +- A quick summary and/or background +- Steps to reproduce + - Be specific! + - Give sample code if you can. +- What you expected would happen +- What actually happens +- Notes (possibly including why you think this might be happening, or stuff you tried that didn't work) + +## Github Actions +We use Github Actions to automate the testing and deployment of the package. The workflow is defined in the `.github/workflows` directory. +To get your code merged into the main branch, you need to pass the tests. Feel free to extend the tests to cover your code. +For a successful test run it's necessary to [set the EIA_TOKEN as secret](https://docs.github.com/en/actions/security-for-github-actions/security-guides/using-secrets-in-github-actions#creating-secrets-for-a-repository) in your Fork. + +## License +By contributing, you agree that your contributions will be licensed under its [MIT License](LICENSE). \ No newline at end of file diff --git a/README.md b/README.md index 3f2622e..19781c6 100644 --- a/README.md +++ b/README.md @@ -227,3 +227,8 @@ Date 2021-01-25 2.602 ... ... ``` + +## Contributing +We love your input! We want to make contributing to this project as easy and transparent as possible. +Read our [CONTRIBUTING.md](CONTRIBUTING.md) to get started. + diff --git a/myeia/api.py b/myeia/api.py index a54348b..de59a59 100644 --- a/myeia/api.py +++ b/myeia/api.py @@ -15,8 +15,7 @@ level=logging.INFO, format="%(asctime)s - %(message)s", datefmt="%d-%b-%y %H:%M:%S" ) -load_dotenv() - +load_dotenv(verbose=True) class API: """ @@ -30,7 +29,13 @@ def __init__( self, token: Optional[str] = None, ): - self.token = token if token else os.getenv("EIA_TOKEN") + if token: + self.token = token + elif os.getenv("EIA_TOKEN"): + self.token = os.getenv("EIA_TOKEN") + else: + raise ValueError('EIA_TOKEN is not set. Please set it in your .env file or environment variables.') + self.base_url = "https://api.eia.gov/v2/" self.header = {"Accept": "*/*"} diff --git a/requirements.txt b/requirements.txt index dafca39..1d57422 100644 --- a/requirements.txt +++ b/requirements.txt @@ -3,4 +3,5 @@ pandas>=1.5.3 pytest>=7.2.1 python-dateutil>=2.9.0 python-dotenv>=0.19.0 -requests>=2.32.0 \ No newline at end of file +requests>=2.32.0 +numpy>=1.21.4 \ No newline at end of file