Fix custom plugin downloaders
Change get_as_dataframe call signature
This commit is contained in:
parent
08c53cf894
commit
52e1d2135b
9 changed files with 156 additions and 105 deletions
|
@ -1130,44 +1130,31 @@ class PlottableModel(Model):
|
|||
values: ClassVar[list[dict[str, str]]] = []
|
||||
|
||||
@classmethod
|
||||
async def get_as_dataframe(cls, model_id=None, where=None, **kwargs):
|
||||
async def get_as_dataframe(cls, item, where=None, **kwargs):
|
||||
"""
|
||||
Get a dataframe for the data.
|
||||
It's quite generic, so subclasses might want to subclass this.
|
||||
"""
|
||||
if where is None:
|
||||
if model_id is None:
|
||||
where_ = None
|
||||
else:
|
||||
where_ = cls.ref_id == model_id
|
||||
else:
|
||||
if model_id is None:
|
||||
where_ = where
|
||||
else:
|
||||
where_ = and_(cls.ref_id == model_id, where)
|
||||
|
||||
if where_ is not None:
|
||||
df = await cls.get_df(where=where_, **kwargs)
|
||||
else:
|
||||
df = await cls.get_df(**kwargs)
|
||||
|
||||
return df
|
||||
where_ = cls.ref_id == item.id
|
||||
if where is not None:
|
||||
where_ = and_(where_, where)
|
||||
return await cls.get_df(where=where_, **kwargs)
|
||||
|
||||
|
||||
class TimePlottableModel(PlottableModel):
|
||||
time: datetime
|
||||
|
||||
@classmethod
|
||||
async def get_as_dataframe(cls, model_id=None, with_only_columns=None, **kwargs):
|
||||
async def get_as_dataframe(cls, item, with_only_columns=None, **kwargs):
|
||||
"""
|
||||
Get the data as a time-indexed dataframe
|
||||
"""
|
||||
if with_only_columns == None:
|
||||
if with_only_columns is None:
|
||||
with_only_columns = [val['name'] for val in cls.values]
|
||||
if 'time' not in with_only_columns:
|
||||
with_only_columns.insert(0, 'time')
|
||||
|
||||
df = await super().get_as_dataframe(model_id=model_id,
|
||||
df = await super().get_as_dataframe(item=item,
|
||||
with_only_columns=with_only_columns,
|
||||
**kwargs)
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
from typing import Any
|
||||
|
||||
from pydantic import BaseModel
|
||||
from pydantic import BaseModel, PrivateAttr
|
||||
|
||||
from gisaf.models.info_item import Tag, InfoItem
|
||||
from gisaf.models.tags import Tags
|
||||
|
@ -112,11 +112,15 @@ class ActionAction(BaseModel):
|
|||
|
||||
|
||||
class Downloader(BaseModel):
|
||||
# plugin: str
|
||||
# downloader: str
|
||||
_plugin: Any = PrivateAttr() # DownloadPlugin
|
||||
roles: list[str] = []
|
||||
name: str
|
||||
icon: str | None = None
|
||||
icon: str | None
|
||||
|
||||
def __init__(self, _plugin, **data):
|
||||
super().__init__(**data)
|
||||
# We generate the value for our private attribute
|
||||
self._plugin = _plugin
|
||||
|
||||
|
||||
class LegendItem(BaseModel):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue