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

Todo resolved - add scope as api parameter carbon.py #257

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 9 additions & 0 deletions dco/YashvardhanSingh.dco
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
1) I, Yashvardhan Singh, certify that all work committed with the commit message
"covered by: YashvardhanSingh.dco" is my original work and I own the copyright
to this work. I agree to contribute this code under the Apache 2.0 license.

2) I understand and agree all contribution including all personal
information I submit with it is maintained indefinitely and may be
redistributed consistent with the open source license(s) involved.

This certification is effective for all code contributed from 12-09-22 to 9999-01-01.
11 changes: 8 additions & 3 deletions gs_quant/api/gs/carbon.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.

//Portions copyright <Yashvardhan Singh>. Licensed under Apache 2.0 license
"""

import logging
from enum import Enum
from typing import Dict, List
Expand Down Expand Up @@ -133,7 +136,8 @@ def get_carbon_analytics(cls,
use_historical_data: bool = False,
normalize_emissions: bool = False,
cards: List[CarbonCard] = [],
analytics_view: CarbonAnalyticsView = CarbonAnalyticsView.LONG) -> Dict:
analytics_view: CarbonAnalyticsView = CarbonAnalyticsView.LONG,
scopes: List[CarbonScope] = []) -> Dict:
url = f'/carbon/{entity_id}?'
url += urlencode(
dict(filter(lambda item: item[1] is not None,
Expand All @@ -144,7 +148,8 @@ def get_carbon_analytics(cls,
useHistoricalData=str(use_historical_data).lower(),
normalizeEmissions=str(normalize_emissions).lower(),
card=[c for c in CarbonCard] if len(cards) == 0 else cards,
analyticsView=analytics_view.value).items())), True)
analyticsView=analytics_view.value).items())),
scope=[s for s in CarbonScope] if len(scopes) == 0 else scopes, True)


# TODO: Add scope as API parameter
return GsSession.current._get(url)