Skip to content

Commit

Permalink
finished read_areas, but need refining
Browse files Browse the repository at this point in the history
  • Loading branch information
mehdiwahada committed Nov 7, 2024
1 parent d99a856 commit 13b3338
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 12 deletions.
16 changes: 16 additions & 0 deletions noCommitForTest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
from antares.api_conf.api_conf import APIconf
from antares.model.study import create_study_api
from antares.service.api_services.study_api import StudyApiService
from tests.antares.services.local_services.conftest import area_fr

api_host="https://antares-web-recette.rte-france.com"

token = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJ7XCJpZFwiOjE1NCxcInR5cGVcIjpcImJvdHNcIixcImltcGVyc29uYXRvclwiOjIsXCJncm91cHNcIjpbXX0iLCJpYXQiOjE3MzA3Mjg4NTgsIm5iZiI6MTczMDcyODg1OCwianRpIjoiM2M3MTJmNTItNTY1Yi00NzFlLTg5NWMtMTVkZDRjY2EyMmFiIiwiZXhwIjo4MDg5NzY4ODU4LCJ0eXBlIjoiYWNjZXNzIiwiZnJlc2giOmZhbHNlfQ.ytXsdGF-Aj7uj9bsnkOsQbU6OtyfU54I0Vl2pVFaOlo"
api = APIconf(api_host, token, False)
#study = create_study_api("ACrafttest-01", "860", api)
#area1=study.create_area("gozo")
#area1.create_thermal_cluster()
#study.create_area("toto")

api_service = StudyApiService(api, "9a5ef197-7f06-4c77-b085-3f360e12b23e")
api_service.read_areas()
54 changes: 42 additions & 12 deletions src/antares/service/api_services/study_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
# SPDX-License-Identifier: MPL-2.0
#
# This file is part of the Antares project.

from typing import Optional, List
import json
from typing import Optional, List, Dict

from antares.api_conf.api_conf import APIconf
from antares.api_conf.request_wrapper import RequestWrapper
Expand All @@ -20,8 +20,9 @@
StudyDeletionError,
StudySettingsUpdateError,
)
from antares.model.area import Area
from antares.model.area import Area, AreaProperties
from antares.model.binding_constraint import BindingConstraint
from antares.model.renewable import RenewableCluster, RenewableClusterProperties
from antares.model.settings.adequacy_patch import AdequacyPatchParameters
from antares.model.settings.advanced_parameters import AdvancedParameters
from antares.model.settings.general import GeneralParameters
Expand All @@ -30,6 +31,8 @@
from antares.model.settings.study_settings import StudySettings
from antares.model.settings.thematic_trimming import ThematicTrimmingParameters
from antares.model.settings.time_series import TimeSeriesParameters
from antares.model.st_storage import STStorage, STStorageProperties
from antares.model.thermal import ThermalCluster, ThermalClusterProperties
from antares.service.base_services import BaseStudyService


Expand Down Expand Up @@ -120,19 +123,46 @@ def read_areas(self) -> List:
json_resp = self._wrapper.get(base_api_url + ui_url).json()

for area in json_resp:
#notes : service =
thermals = dict()
renewables = dict()
st_storage = dict()

area_url = base_api_url + "/" + f"{area}/"
json_thermal = self._wrapper.get(area_url + url_thermal).json()
json_renewable = self._wrapper.get(area_url + url_renewable).json()
json_st_storage = self._wrapper.get(area_url + url_st_storage).json()
json_properties = self._wrapper.get(area_url + url_properties_form).json()
obj_area = Area(area, self.config, self.config, self.config, self.config)
#obj_area._st_storages = obj_area.create_st_storage(json_st_storage["name"],json_st_storage)
print(json_thermal)
print(json_renewable)
print(json_st_storage)
print(json_properties["energyCostUnsupplied"])
#area_list.append(obj_area)

for therm in json_thermal:
id_therm = therm.pop('id')
name = therm.pop('name')

thermal_props=ThermalClusterProperties(**therm)
therm_cluster=ThermalCluster(self.config, area, name, thermal_props)
thermals.update({id_therm: therm_cluster})

for renew in json_renewable:
id_renew = renew.pop('id')
name = renew.pop('name')

renew_props=RenewableClusterProperties(**renew)
renew_cluster=RenewableCluster(self.config, area, name, renew_props)
renewables.update({id_renew: renew_cluster})

for storage in json_st_storage:
id_storage = storage.pop('id')
name = storage.pop('name')

storage_props = STStorageProperties(**storage)
st_storage_cl = STStorage(self.config, area, name, storage_props)
st_storage.update({id_storage:st_storage_cl})

area_obj=Area(area,
self.config, self.config,
self.config, self.config,
renewables=renewables,thermals=thermals,
st_storages=st_storage, properties=json_properties)

area_list.append(area_obj)

return area_list
return area_list

0 comments on commit 13b3338

Please sign in to comment.