Skip to content

Commit c95bb21

Browse files
committed
initial commit
1 parent 76d5db4 commit c95bb21

File tree

5 files changed

+18
-13
lines changed

5 files changed

+18
-13
lines changed

CHANGELOG.md

+5
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,11 @@ Classify the change according to the following categories:
2626
##### Removed
2727
### Patches
2828

29+
## gridRE
30+
### Minor Updates
31+
#### Changed
32+
- Changed v3 endpoint "cambium_emissions_profile" to "cambium_profile"
33+
2934
## v3.10.2
3035
### Minor Updates
3136
##### Changed

julia_src/http.jl

+4-4
Original file line numberDiff line numberDiff line change
@@ -348,9 +348,9 @@ function avert_emissions_profile(req::HTTP.Request)
348348
return HTTP.Response(200, JSON.json(data))
349349
end
350350

351-
function cambium_emissions_profile(req::HTTP.Request)
351+
function cambium_profile(req::HTTP.Request)
352352
d = JSON.parse(String(req.body))
353-
@info "Getting Cambium CO2 emissions profile..."
353+
@info "Getting emissions or clean energy data from Cambium..."
354354
data = Dict()
355355
error_response = Dict()
356356
try
@@ -360,7 +360,7 @@ function cambium_emissions_profile(req::HTTP.Request)
360360
lifetime = typeof(d["lifetime"]) == String ? parse(Int, d["lifetime"]) : d["lifetime"]
361361
load_year = typeof(d["load_year"]) == String ? parse(Int, d["load_year"]) : d["load_year"]
362362

363-
data = reoptjl.cambium_emissions_profile(;scenario= d["scenario"],
363+
data = reoptjl.cambium_profile(;scenario= d["scenario"],
364364
location_type = d["location_type"],
365365
latitude=latitude,
366366
longitude=longitude,
@@ -597,7 +597,7 @@ HTTP.register!(ROUTER, "POST", "/erp", erp)
597597
HTTP.register!(ROUTER, "POST", "/ghpghx", ghpghx)
598598
HTTP.register!(ROUTER, "GET", "/chp_defaults", chp_defaults)
599599
HTTP.register!(ROUTER, "GET", "/avert_emissions_profile", avert_emissions_profile)
600-
HTTP.register!(ROUTER, "GET", "/cambium_emissions_profile", cambium_emissions_profile)
600+
HTTP.register!(ROUTER, "GET", "/cambium_profile", cambium_profile)
601601
HTTP.register!(ROUTER, "GET", "/easiur_costs", easiur_costs)
602602
HTTP.register!(ROUTER, "GET", "/simulated_load", simulated_load)
603603
HTTP.register!(ROUTER, "GET", "/absorption_chiller_defaults", absorption_chiller_defaults)

reoptjl/test/test_http_endpoints.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -231,8 +231,8 @@ def test_avert_emissions_profile_endpoint(self):
231231
self.assertTrue("error" in view_response)
232232

233233

234-
def test_cambium_emissions_profile_endpoint(self):
235-
# Call to the django view endpoint v3/cambium_emissions_profile which calls the http.jl endpoint
234+
def test_cambium_profile_endpoint(self):
235+
# Call to the django view endpoint v3/cambium_profile which calls the http.jl endpoint
236236
#case 1: location in CONUS (Seattle, WA)
237237
inputs = {
238238
"load_year": 2021,
@@ -245,7 +245,7 @@ def test_cambium_emissions_profile_endpoint(self):
245245
"metric_col": "lrmer_co2e",
246246
"grid_level": "enduse"
247247
}
248-
resp = self.api_client.get(f'/v3/cambium_emissions_profile', data=inputs)
248+
resp = self.api_client.get(f'/v3/cambium_profile', data=inputs)
249249
self.assertHttpOK(resp)
250250
view_response = json.loads(resp.content)
251251
self.assertEquals(view_response["metric_col"], "lrmer_co2e")
@@ -254,21 +254,21 @@ def test_cambium_emissions_profile_endpoint(self):
254254
#case 2: location off shore of NJ (works for AVERT, not Cambium)
255255
inputs["latitude"] = 39.034417
256256
inputs["longitude"] = -74.759292
257-
resp = self.api_client.get(f'/v3/cambium_emissions_profile', data=inputs)
257+
resp = self.api_client.get(f'/v3/cambium_profile', data=inputs)
258258
self.assertHttpBadRequest(resp)
259259
view_response = json.loads(resp.content)
260260
self.assertTrue("error" in view_response)
261261
#case 3: Honolulu, HI (works for AVERT but not Cambium)
262262
inputs["latitude"] = 21.3099
263263
inputs["longitude"] = -157.8581
264-
resp = self.api_client.get(f'/v3/cambium_emissions_profile', data=inputs)
264+
resp = self.api_client.get(f'/v3/cambium_profile', data=inputs)
265265
self.assertHttpBadRequest(resp)
266266
view_response = json.loads(resp.content)
267267
self.assertTrue("error" in view_response)
268268
#case 4: location well outside of US (does not work)
269269
inputs["latitude"] = 0.0
270270
inputs["longitude"] = 0.0
271-
resp = self.api_client.get(f'/v3/cambium_emissions_profile', data=inputs)
271+
resp = self.api_client.get(f'/v3/cambium_profile', data=inputs)
272272
self.assertHttpBadRequest(resp)
273273
view_response = json.loads(resp.content)
274274
self.assertTrue("error" in view_response)

reoptjl/urls.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
re_path(r'^chp_defaults/?$', views.chp_defaults),
1212
re_path(r'^absorption_chiller_defaults/?$', views.absorption_chiller_defaults),
1313
re_path(r'^avert_emissions_profile/?$', views.avert_emissions_profile),
14-
re_path(r'^cambium_emissions_profile/?$', views.cambium_emissions_profile),
14+
re_path(r'^cambium_profile/?$', views.cambium_profile),
1515
re_path(r'^easiur_costs/?$', views.easiur_costs),
1616
re_path(r'^simulated_load/?$', views.simulated_load),
1717
re_path(r'^user/(?P<user_uuid>[0-9a-f-]+)/summary/?$', views.summary),

reoptjl/views.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1452,7 +1452,7 @@ def avert_emissions_profile(request):
14521452
log.error(debug_msg)
14531453
return JsonResponse({"Error": "Unexpected Error. Please check your input parameters and contact [email protected] if problems persist."}, status=500)
14541454

1455-
def cambium_emissions_profile(request):
1455+
def cambium_profile(request):
14561456
try:
14571457
inputs = {
14581458
"scenario": request.GET['scenario'],
@@ -1471,7 +1471,7 @@ def cambium_emissions_profile(request):
14711471
"julia"
14721472
)
14731473
http_jl_response = requests.get(
1474-
"http://" + julia_host + ":8081/cambium_emissions_profile/",
1474+
"http://" + julia_host + ":8081/cambium_profile/",
14751475
json=inputs
14761476
)
14771477
response = JsonResponse(

0 commit comments

Comments
 (0)