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

Fix duplicate names for same process by counting up processes in adapter #66

Merged
merged 7 commits into from
Mar 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/linter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v1
with:
python-version: 3.9
python-version: "3.10"

- name: Install Python dependencies
run: pip install black flake8 isort
run: pip install black==20.8b1 flake8 isort click==8.0.4

- name: Black
if: success() || failure()
Expand Down
7 changes: 6 additions & 1 deletion data_adapter_oemof/adapters.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import logging
from collections import Counter

from oemof.tabular import facades
from oemof.tabular._facade import Facade
Expand All @@ -17,6 +18,7 @@ class Adapter:
Field(name="region", type=str),
Field(name="year", type=int),
)
counter: int = Counter()

def __init__(self, struct: dict, mapper: Mapper):
self.facade_dict = self.get_default_parameters(struct, mapper)
Expand All @@ -34,7 +36,10 @@ def get_default_parameters(self, struct: dict, mapper: Mapper) -> dict:
defaults.update(
{
"name": calculations.get_name(
mapper.get("region"), mapper.get("carrier"), mapper.get("tech")
mapper.get("region"),
mapper.get("carrier"),
mapper.get("tech"),
self.counter,
Comment on lines +39 to +42
Copy link
Contributor

Choose a reason for hiding this comment

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

Why dont we pass the process name? defaults.update({"name": mapper.process_name})

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good idea. Counting must still be added

Copy link
Contributor

Choose a reason for hiding this comment

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

I added it to #71

)
}
)
Expand Down
4 changes: 2 additions & 2 deletions data_adapter_oemof/calculations.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ def decorated_func(*args, **kwargs):


@calculation
def get_name(region, carrier, tech):
return f"{region}-{carrier}-{tech}"
def get_name(region, carrier, tech, counter):
return f"{region}-{carrier}-{tech}--{counter.next()}"


@calculation
Expand Down
Loading
Loading