Skip to content

Fetch data directly from pyRAT's api#30

Merged
K-Meech merged 31 commits into
mainfrom
km/pyrat-api
Apr 13, 2026
Merged

Fetch data directly from pyRAT's api#30
K-Meech merged 31 commits into
mainfrom
km/pyrat-api

Conversation

@K-Meech

@K-Meech K-Meech commented Apr 13, 2026

Copy link
Copy Markdown
Collaborator

Description

What is this PR

  • Bug fix
  • Addition of a new feature
  • Other

Why is this PR needed?
So far, we have analysed csv files of historical exported data. Ideally, we could fetch this data directly from a pyRAT instance via their REST api.

What does this PR do?

  • adds a new module to fetch data directly from the pyRAT api
  • This expects PYRAT_URL, PYRAT_CLIENT_TOKEN and PYRAT_USER_TOKEN to be set as environment variables with the relevant values. (this means it can connect to any pyRAT instance, as long as the correct values are set)
  • Adds tests using mock pyRAT response data (all added as .json files to the GIN repo). I'm using mock responses so we are never accessing real data or the real pyRAT server during the tests.
  • I added a general pooch_data_path function (replacing the previous fixtures for each test dataset), so that any dataset can easily be fetched via name. This reduces the number of lines of code needed to manage this, especially now we have more datasets on GIN.

References

Closes #4

How has this PR been tested?

Tests have been added for all new functionality

Is this a breaking change?

No

Does this PR require an update to the documentation?

Relevant docstrings have been updated

Checklist:

  • The code has been tested locally
  • Tests have been added to cover all new functionality
  • The documentation has been updated to reflect any changes
  • The code has been formatted with pre-commit

K-Meech added 30 commits March 25, 2026 15:08
@K-Meech K-Meech requested a review from a team April 13, 2026 12:48

@adamltyson adamltyson left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All looks sensible to me. My only suggestion would be to refactor in such a way that it's a bit easier to add support for other colony management systems in the future. Something like oscar/colony_management/pyrat?

@K-Meech

K-Meech commented Apr 13, 2026

Copy link
Copy Markdown
Collaborator Author

Thanks @adamltyson - good point! I've made that change now, so I'll go ahead and merge.

@K-Meech K-Meech merged commit f089d47 into main Apr 13, 2026
16 of 21 checks passed
@K-Meech K-Meech deleted the km/pyrat-api branch April 13, 2026 15:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Retrieve historical data directly from the pyRAT api

2 participants