-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add iamc filter for tabulate/ list runs (#54)
* add iamc filter for tabulate/ list runs * add test: run iamc filter only returns items with existing datapoints
- Loading branch information
Showing
2 changed files
with
82 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,27 @@ | ||
from ixmp4.data.db import filters as base | ||
from ixmp4.db import filters | ||
from ixmp4.data.db.iamc.datapoint import get_datapoint_model | ||
from ixmp4.data.db.iamc.timeseries import TimeSeries | ||
from ixmp4.data.db.run.model import Run | ||
from ixmp4.db import filters, utils | ||
|
||
|
||
class IamcRunFilter(filters.BaseFilter, metaclass=filters.FilterMeta): | ||
region: base.RegionFilter | ||
variable: base.VariableFilter | ||
unit: base.UnitFilter | ||
|
||
def join(self, exc, session=None): | ||
if not utils.is_joined(exc, TimeSeries): | ||
exc = exc.join(TimeSeries, onclause=TimeSeries.run__id == Run.id) | ||
|
||
model = get_datapoint_model(session) | ||
if not utils.is_joined(exc, model): | ||
exc = exc.join(model, onclause=model.time_series__id == TimeSeries.id) | ||
return exc | ||
|
||
|
||
class RunFilter(base.RunFilter, metaclass=filters.FilterMeta): | ||
iamc: IamcRunFilter | filters.Boolean | ||
|
||
def join(self, exc, **kwargs): | ||
return exc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters