Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Dynamic Exposure
Global Dynamic Exposure
losscalculator
Commits
358dee2e
Commit
358dee2e
authored
Dec 13, 2021
by
Marius Kriegerowski
Browse files
optimize imports increase timout
parent
d5ec7a38
Pipeline
#36971
failed with stage
in 4 minutes and 38 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
losscalculator/api.py
View file @
358dee2e
...
@@ -13,12 +13,11 @@ from fastapi import FastAPI, Body, HTTPException
...
@@ -13,12 +13,11 @@ from fastapi import FastAPI, Body, HTTPException
from
fastapi.responses
import
FileResponse
from
fastapi.responses
import
FileResponse
from
geopy.adapters
import
AioHTTPAdapter
from
geopy.adapters
import
AioHTTPAdapter
from
geopy.geocoders
import
Nominatim
from
geopy.geocoders
import
Nominatim
from
obspy.io.quakeml.core
import
Unpickler
from
starlette.background
import
BackgroundTask
from
starlette.background
import
BackgroundTask
from
losscalculator.damage_calculator
import
damage_calculator
from
losscalculator.damage_calculator
import
damage_calculator
from
losscalculator.ground_motion
import
GMField
from
losscalculator.ground_motion
import
GMField
from
obspy.io.quakeml.core
import
Unpickler
logger
=
logging
.
getLogger
(
__name__
)
logger
=
logging
.
getLogger
(
__name__
)
...
@@ -92,6 +91,7 @@ async def region_from_event(event_quakeml: str) -> str:
...
@@ -92,6 +91,7 @@ async def region_from_event(event_quakeml: str) -> str:
async
with
Nominatim
(
async
with
Nominatim
(
user_agent
=
"losscalculator"
,
user_agent
=
"losscalculator"
,
adapter_factory
=
AioHTTPAdapter
,
adapter_factory
=
AioHTTPAdapter
,
timeout
=
3
,
)
as
geolocator
:
)
as
geolocator
:
location
=
await
geolocator
.
reverse
(
f
"
{
origin
.
latitude
}
,
{
origin
.
longitude
}
"
)
location
=
await
geolocator
.
reverse
(
f
"
{
origin
.
latitude
}
,
{
origin
.
longitude
}
"
)
...
@@ -144,10 +144,7 @@ async def loss(event_quakeml: str = Body(...)):
...
@@ -144,10 +144,7 @@ async def loss(event_quakeml: str = Body(...)):
print
(
"created temporary result file"
,
result_filepath
)
print
(
"created temporary result file"
,
result_filepath
)
damage_calculator
(
damage_calculator
(
# exposure_filepath=exposure,
# fragility_source=fragility,
intensity_measure_map_filepath
=
intensity_map
,
intensity_measure_map_filepath
=
intensity_map
,
# taxonomy_map_filepath=taxonomy,
gm_field
=
gm_field
,
gm_field
=
gm_field
,
use_xml_fragilities
=
False
,
use_xml_fragilities
=
False
,
result_filepath
=
result_filepath
,
result_filepath
=
result_filepath
,
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment