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

Passing the power capacity with a sensor ID is not supported #984

Closed
victorgarcia98 opened this issue Feb 20, 2024 · 2 comments · Fixed by #987
Closed

Passing the power capacity with a sensor ID is not supported #984

victorgarcia98 opened this issue Feb 20, 2024 · 2 comments · Fixed by #987
Assignees
Labels
API bug Something isn't working CLI Scheduling
Milestone

Comments

@victorgarcia98
Copy link
Contributor

          @victorgarcia98 I don't think we actually support passing this as a sensor ID. It looks like in `MetaStorageScheduler._prepare` we only support a `Quantity` right now:

# Check for required Sensor attributes
power_capacity_in_mw = self.flex_model.get(
"power_capacity_in_mw",
self.sensor.get_attribute("capacity_in_mw", None),
)
if power_capacity_in_mw is None:
raise ValueError(
"Power capacity is not defined in the sensor attributes or the flex-model."
)
if isinstance(power_capacity_in_mw, ur.Quantity):
power_capacity_in_mw = power_capacity_in_mw.magnitude
if not (
isinstance(power_capacity_in_mw, float)
or isinstance(power_capacity_in_mw, int)
):
raise ValueError(
"The only supported types for the power capacity are int and float."
)

Originally posted by @Flix6x in #897 (comment)

@victorgarcia98 victorgarcia98 changed the title Passing the power capacity as a sensor ID is not supported Passing the power capacity with a sensor ID is not supported Feb 20, 2024
@Flix6x Flix6x added bug Something isn't working API Scheduling CLI labels Feb 20, 2024
@Flix6x
Copy link
Contributor

Flix6x commented Feb 20, 2024

Rather than reverting the schema change for the site-power-capacity back to QuantityField, I believe the implementation is straightforward.

In MetaStorageScheduler._prepare the site power capacity is used as a max_value of get_continuous_series_sensor_or_quantity, which uses it to do a .clip(upper=max_value) under the hood. Here, Pandas already supports passing a pd.Series.

So, it should be a matter of simply adjusting some type annotations and fetching the sensor data using get_continuous_series_sensor_or_quantity instead of raising in case the site power capacity is pointing to a sensor.

@Flix6x Flix6x added this to the 0.18.2 milestone Feb 20, 2024
@victorgarcia98 victorgarcia98 self-assigned this Feb 20, 2024
@victorgarcia98
Copy link
Contributor Author

Good idea, I'll work on it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API bug Something isn't working CLI Scheduling
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants