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

feat: create the CLI command flexmeasures show reporters #686

Merged
merged 7 commits into from May 19, 2023

Conversation

victorgarcia98
Copy link
Contributor

An interesting feature after the flexmeasures add report is the possibility to show all the available reporters. This PR creates a new command that list all the reporter classes that can be used: all the classes in flexmeasures.data.models.reporting and in the main file of every plugin (init.py) that subclass Reporter.

Usage

$ flexmeasures show reporters

Output example

Reporters:

name              version  author
--------------  ---------  --------
PandasReporter          1  None

Signed-off-by: Victor Garcia Reolid <victor@seita.nl>
Signed-off-by: Victor Garcia Reolid <victor@seita.nl>
Copy link
Contributor

@Flix6x Flix6x left a comment

Choose a reason for hiding this comment

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

Nice. Looking forward to having this for schedulers and forecasters, too.

Just two small change requests.

And can you create follow-up issues for schedulers and forecasters?

Schedulers:

Forecasters:

  • Forecasters cannot be registered by plugins yet, but we want to follow the same concepts as for reporters and schedulers.

flexmeasures/cli/data_show.py Outdated Show resolved Hide resolved
flexmeasures/cli/data_show.py Show resolved Hide resolved
style: print empty string when the author is missing

Signed-off-by: Victor Garcia Reolid <victor@seita.nl>
Copy link
Contributor

@Flix6x Flix6x left a comment

Choose a reason for hiding this comment

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

I'd put the module last, not first. The name is most likely the bit of information that the user is looking for, so should be first.

Still missing:

  • changelog entry
  • new entry in documentation/cli/commands.rst

Signed-off-by: Victor Garcia Reolid <victor@seita.nl>
Signed-off-by: Victor Garcia Reolid <victor@seita.nl>
Signed-off-by: Victor Garcia Reolid <victor@seita.nl>
@victorgarcia98 victorgarcia98 merged commit c412802 into 642-add-report-cli-command-2 May 19, 2023
5 checks passed
@victorgarcia98 victorgarcia98 deleted the show-reporters-command branch May 19, 2023 11:01
Flix6x added a commit that referenced this pull request May 29, 2023
* Creating Reporter and PandasReporter classes with their corresponding report_config schemas.

Signed-off-by: victor <victor@seita.nl>

* Added Tibber Reporter.

Signed-off-by: victor <victor@seita.nl>

* - Fixing wong DA Price value.
- Renaming BWV and EB to english words.
- Simplifying calculation (pandas pipeline).
- Adding units to sensors.
- Changing units from EUR/kWh to EUR/MWh
- Adding assert to check maximum error
- deserialize_report_config -> deserialize_reporter_config
- Warning when a string starting with  `@` is used in the method query or eval.
- Making process_pandas_args, process_pandas_kwargs and apply_transformation private methods.

Signed-off-by: victor <victor@seita.nl>

* Updating VAT units.

Signed-off-by: victor <victor@seita.nl>

* - Attatching report to sensor
- Output type of compute is BeliefDataFrame
- Added a global input resolution to schem
- ISO datetime and timedeltas
- start, end and input_resolution are considered serialized when passed to the method compute
- assert to check that result resolution = sensor resolution

Signed-off-by: victor <victor@seita.nl>

* Fixing wrong arguments to search_beliefs method.

Signed-off-by: victor <victor@seita.nl>

* FIxing wrong type conversion logic.

Signed-off-by: victor <victor@seita.nl>

* Small reporter fixes (#647)

* No return value

Signed-off-by: F.N. Claessen <felix@seita.nl>

* typo

Signed-off-by: F.N. Claessen <felix@seita.nl>

* plural

Signed-off-by: F.N. Claessen <felix@seita.nl>

* indentation

Signed-off-by: F.N. Claessen <felix@seita.nl>

* fix return type annotations

Signed-off-by: F.N. Claessen <felix@seita.nl>

* format docstring example

Signed-off-by: F.N. Claessen <felix@seita.nl>

* add type annotations

Signed-off-by: F.N. Claessen <felix@seita.nl>

* predefine instance attributes

Signed-off-by: F.N. Claessen <felix@seita.nl>

* remove redundant variable

Signed-off-by: F.N. Claessen <felix@seita.nl>

* grammar

Signed-off-by: F.N. Claessen <felix@seita.nl>

* support aliases

Signed-off-by: F.N. Claessen <felix@seita.nl>

* grammar/typos

Signed-off-by: F.N. Claessen <felix@seita.nl>

* test exact match

Signed-off-by: F.N. Claessen <felix@seita.nl>

---------

Signed-off-by: F.N. Claessen <felix@seita.nl>

* Add superclass to Reporter that will be common to all three data generator classes: Reporter, Scheduler, Forecaster.

Signed-off-by: victor <victor@seita.nl>

* Add start, end, resolution, beliefs_after and beliefs_before to the `compute` method signature.

Signed-off-by: victor <victor@seita.nl>

* Add FLEXMEASURES_DEFAULT_DATASOURCE config to be the feault datasource for data generators.

Signed-off-by: victor <victor@seita.nl>

* Fixing wrong input type.

Signed-off-by: victor <victor@seita.nl>

* Rename DataGenerator class to DataGeneratorMixin

Signed-off-by: victor <victor@seita.nl>

* Reduce logging level from warning to debug.

Signed-off-by: victor <victor@seita.nl>

* Register Reporter to the app context.

Signed-off-by: Victor Garcia Reolid <victor@seita.nl>

* Allowing to use BeliefsDataFrame specific method in the schema.

Signed-off-by: Victor Garcia Reolid <victor@seita.nl>

* Fixed wrong method. TODO: test with a plugin.

Signed-off-by: Victor Garcia Reolid <victor@seita.nl>

* Using module name instead of the module object.

Signed-off-by: Victor Garcia Reolid <victor@seita.nl>

* use belief_time instead of beliefs_before and beliefs_after (#652)

Signed-off-by: F.N. Claessen <felix@seita.nl>

* Fixing example.

Signed-off-by: Victor Garcia Reolid <victor@seita.nl>

* Fixing grammar.

Signed-off-by: Victor Garcia Reolid <victor@seita.nl>

* Require at least 1 input sensor for the tb_query_config.

Signed-off-by: Victor Garcia Reolid <victor@seita.nl>

* Bug fix: compute function was overriding the variables to the default value (None)

Signed-off-by: Victor Garcia Reolid <victor@seita.nl>

* Changing end to get 24h and fix assert condition to detect NaN.

Signed-off-by: Victor Garcia Reolid <victor@seita.nl>

* Adding belief time variable to schema.

Signed-off-by: Victor Garcia Reolid <victor@seita.nl>

* Avoid deserializing multiple times.

Signed-off-by: Victor Garcia Reolid <victor@seita.nl>

* Add command flexmeasures add report.

Signed-off-by: Victor Garcia Reolid <victor@seita.nl>

* Add scope="module" to avoid recreating objects in DB.

Signed-off-by: Victor Garcia Reolid <victor@seita.nl>

* Skip tests and fixtures in GitHub.

Signed-off-by: Victor Garcia Reolid <victor@seita.nl>

* style(cli): state that --last-X can be used instead of start or end.

* style(cli): add three dots after message

* style(cli): add CLI message to show that the computation is running.

* style(cli): add type hint for reporter and result.

* style(cli.utils): renaming function.
style(cli.utils): changing return type.
style(cli.utils): improving docstring.
style(cli.utils): using utils functions.
style(cli.data_add): moving validation of inputs to CLI function.

* style(cli.data_add): replace --save-to-database with --dry-run.

* feat(cli.data_add): default start to the latest time the reporter sensor has data and end to datetime.now().

* fix: setting a right default value for the timezone.

* style: using click parameter File instead of Path.

* style: add comments

* fix: remove time paramters (start, end, ...) from the Reporter class attributes.

Signed-off-by: Victor Garcia Reolid <victor@seita.nl>

* style: print success at the end.

Signed-off-by: Victor Garcia Reolid <victor@seita.nl>

* fix: add test for get_timerange_from_flag and fix some bugs

Signed-off-by: Victor Garcia Reolid <victor@seita.nl>

* style: move fixtures to the file conftest

Signed-off-by: Victor Garcia Reolid <victor@seita.nl>

* style: add docstring to the fixture setup_dummy_data

Signed-off-by: Victor Garcia Reolid <victor@seita.nl>

* style: typo

Signed-off-by: Victor Garcia Reolid <victor@seita.nl>

* feat: check for the right values

Signed-off-by: Victor Garcia Reolid <victor@seita.nl>

* style: delete redundant test

Signed-off-by: Victor Garcia Reolid <victor@seita.nl>

* style: improve docstring

Signed-off-by: Victor Garcia Reolid <victor@seita.nl>

* style: improving docstring.

Signed-off-by: Victor Garcia Reolid <victor@seita.nl>

* style: removing "In"s

Signed-off-by: Victor Garcia Reolid <victor@seita.nl>

* style: change comments from triple quotes to block style

Signed-off-by: Victor Garcia Reolid <victor@seita.nl>

* style: add a more informative test check

Signed-off-by: Victor Garcia Reolid <victor@seita.nl>

* style: add comment

Signed-off-by: Victor Garcia Reolid <victor@seita.nl>

* Small fixes from reviewing the report cli command (#685)

* style: help texts

Signed-off-by: F.N. Claessen <felix@seita.nl>

* style: capitalization

Signed-off-by: F.N. Claessen <felix@seita.nl>

* style: punctuation

Signed-off-by: F.N. Claessen <felix@seita.nl>

* feature: warn in case of empty report

Signed-off-by: F.N. Claessen <felix@seita.nl>

* fix: save result rather than reporter

Signed-off-by: F.N. Claessen <felix@seita.nl>

* feature: more informative error message for mismatching event resolutions of report results

Signed-off-by: F.N. Claessen <felix@seita.nl>

* feature: print out report in case of --dry-run

Signed-off-by: F.N. Claessen <felix@seita.nl>

* black

Signed-off-by: F.N. Claessen <felix@seita.nl>

* style: spacing

Signed-off-by: F.N. Claessen <felix@seita.nl>

---------

Signed-off-by: F.N. Claessen <felix@seita.nl>

* fix: change dry_run default to False

Signed-off-by: Victor Garcia Reolid <victor@seita.nl>

* test: update field name

Signed-off-by: Victor Garcia Reolid <victor@seita.nl>

* fix: use timezone in get_timerange_from_flag
fix: use get_timezone() for the default value

Signed-off-by: Victor Garcia Reolid <victor@seita.nl>

* style: typo

Signed-off-by: Victor Garcia Reolid <victor@seita.nl>

* style: week -> day

Signed-off-by: Victor Garcia Reolid <victor@seita.nl>

* refactor: last_week -> last_7_days

Signed-off-by: Victor Garcia Reolid <victor@seita.nl>

* feat: add datasource to report

Signed-off-by: Victor Garcia Reolid <victor@seita.nl>

* feat: set reporter_class default value to ReporterClass

Signed-off-by: Victor Garcia Reolid <victor@seita.nl>

* style: simplify reporter-config file param name

Signed-off-by: Victor Garcia Reolid <victor@seita.nl>

* style: clarify help message

Signed-off-by: Victor Garcia Reolid <victor@seita.nl>

* style: update repoter_config param click

Signed-off-by: Victor Garcia Reolid <victor@seita.nl>

* test: update cli parameter names

Signed-off-by: Victor Garcia Reolid <victor@seita.nl>

* feat: fill missing indexes in beliefdataframes with default values

Signed-off-by: Victor Garcia Reolid <victor@seita.nl>

* style: combine two lines into one

Signed-off-by: Victor Garcia Reolid <victor@seita.nl>

* test: update tests to check with considering that BeliefDataframe is the output type

Signed-off-by: Victor Garcia Reolid <victor@seita.nl>

* feat: add data_source property to shared mixin

Signed-off-by: Victor Garcia Reolid <victor@seita.nl>

* fix: potential bug -> multiple data source creation

Signed-off-by: Victor Garcia Reolid <victor@seita.nl>

* fix: issubclass instead of isinstance

Signed-off-by: Victor Garcia Reolid <victor@seita.nl>

* docs: clarify test_add_reporter docstring

Signed-off-by: Victor Garcia Reolid <victor@seita.nl>

* feat: add function to apply an offset chain

Signed-off-by: Victor Garcia Reolid <victor@seita.nl>

* feat: add start_offset and end_offset to add_report

Signed-off-by: Victor Garcia Reolid <victor@seita.nl>

* feat: add start and end offsets

Signed-off-by: Victor Garcia Reolid <victor@seita.nl>

* docs: add entry for `flexmeasures add report`

Signed-off-by: Victor Garcia Reolid <victor@seita.nl>

* feat: create the CLI command `flexmeasures show reporters` (#686)

* feat: create show reporter command

Signed-off-by: Victor Garcia Reolid <victor@seita.nl>

* style: add hint to list reporters

Signed-off-by: Victor Garcia Reolid <victor@seita.nl>

* style: add module name
style: print empty string when the author is missing

Signed-off-by: Victor Garcia Reolid <victor@seita.nl>

* style: change column order

Signed-off-by: Victor Garcia Reolid <victor@seita.nl>

* docs: add entry for PR #686

Signed-off-by: Victor Garcia Reolid <victor@seita.nl>

* docs: add command flexmeasures show reporters

Signed-off-by: Victor Garcia Reolid <victor@seita.nl>

---------

Signed-off-by: Victor Garcia Reolid <victor@seita.nl>

* docs: add entry to changelog

Signed-off-by: Victor Garcia Reolid <victor@seita.nl>

* Small report cli fixes (#691)

* style: capitalize CSV

Signed-off-by: F.N. Claessen <felix@seita.nl>

* fix: reporter is no longer a required parameter

Signed-off-by: F.N. Claessen <felix@seita.nl>

* style: required parameters on top

Signed-off-by: F.N. Claessen <felix@seita.nl>

* style: fix parameter name in docstring

Signed-off-by: F.N. Claessen <felix@seita.nl>

* fix: avoid converting dt type

Signed-off-by: F.N. Claessen <felix@seita.nl>

* feature: add test case with timezone

Signed-off-by: F.N. Claessen <felix@seita.nl>

* feature: add test case for Pandas structure

Signed-off-by: F.N. Claessen <felix@seita.nl>

* fix: type annotations

Signed-off-by: F.N. Claessen <felix@seita.nl>

* fix: use parameter 'end'

Signed-off-by: F.N. Claessen <felix@seita.nl>

* style: fix type annotation

Signed-off-by: F.N. Claessen <felix@seita.nl>

* style: justified indentation

Signed-off-by: F.N. Claessen <felix@seita.nl>

---------

Signed-off-by: F.N. Claessen <felix@seita.nl>

* docs: update PR number in the changelog

Signed-off-by: Victor Garcia Reolid <victor@seita.nl>

* fix: changing types

Signed-off-by: Victor Garcia Reolid <victor@seita.nl>

* test: move fixture to conftest

Signed-off-by: Victor Garcia Reolid <victor@seita.nl>

* fix: handle empty result

Signed-off-by: Victor Garcia Reolid <victor@seita.nl>

* style: fix inaccurate message to the user

Signed-off-by: Victor Garcia Reolid <victor@seita.nl>

* refactor: remove last-X parameters

Signed-off-by: Victor Garcia Reolid <victor@seita.nl>

---------

Signed-off-by: victor <victor@seita.nl>
Signed-off-by: F.N. Claessen <felix@seita.nl>
Signed-off-by: Victor Garcia Reolid <victor@seita.nl>
Co-authored-by: Felix Claessen <30658763+Flix6x@users.noreply.github.com>
Flix6x added a commit that referenced this pull request Jun 9, 2023
This PR builds upon the previous work done in PR #686, which introduced the command flexmeasures show reporters. Now, we extend this functionality to include the Scheduler class as well. The new command, flexmeasures show schedulers, allows users to view a comprehensive list of all available schedulers within flexmeasures.


* added a new show schedulers cli command

Signed-off-by: Ahmad-Wahid <59763365+Ahmad-Wahid@users.noreply.github.com>

* add changes description in changelog

Signed-off-by: Ahmad-Wahid <59763365+Ahmad-Wahid@users.noreply.github.com>

* created a generic function which creates a list of an item attributes

Signed-off-by: Ahmad-Wahid <59763365+Ahmad-Wahid@users.noreply.github.com>

* Load schedulers from plugins, too

Signed-off-by: F.N. Claessen <felix@seita.nl>

* Find classes in __init__.py files, too

Signed-off-by: F.N. Claessen <felix@seita.nl>

* fix: extract classes from the base module as well

Signed-off-by: Victor Garcia Reolid <victor@seita.nl>

---------

Signed-off-by: Ahmad-Wahid <59763365+Ahmad-Wahid@users.noreply.github.com>
Signed-off-by: F.N. Claessen <felix@seita.nl>
Signed-off-by: Victor Garcia Reolid <victor@seita.nl>
Co-authored-by: F.N. Claessen <felix@seita.nl>
Co-authored-by: Victor Garcia Reolid <victor@seita.nl>
@Flix6x Flix6x added this to the 0.14.0 milestone Jun 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants