sedos-project / data_adapter_oemof

This respository holds the data adapters to connect oemof with the OEDatamodel-concrete.
GNU Affero General Public License v3.0
0 stars 1 forks source link

solph arguments are not added to datapackage #53

Closed FelixMau closed 8 months ago

FelixMau commented 8 months ago

When building a datapackage from data that contains a solph argument the argument is getting lost. For illistrating the issue there is a data mock for storage with a solph argument as well as the corresponding datapackage with missing argument. This issue occours because the get_fields function uses dataclass.fields and the oemof.solph components are not dataclases

I think we could solve this two ways:

henhuy commented 8 months ago

Thanks for pointing this out! You are right oemof.solph attributes which are not adressed in corresponding facade class can not be read automatically. Instead, such attributes must be handled by extra_fields in Adapter (which is faster in terms of coding cycles than adding them to Facade). When adding them in StorageAdapter like this:

class StorageAdapter(Adapter):
    """
    StorageAdapter
    """

    type = "storage"
    facade = facades.Storage
    extra_fields = (
        Field(name="name", type=str),
        Field(name="type", type=str),
        Field(name="region", type=str),
        Field(name="year", type=int),
        Field(name="invest_relation_output_capacity", type=list),
    )

variable is written to datapackage file.

Unfortunately, as I just saw, periodic values are neglected therby (only first value is taken). This has to be handled within another issue.I will close this one, as behaviour is as expected...