Nicolas Pierson commited on
^^
Browse files- src/pages/1_Historical_Prices.py +19 -19
src/pages/1_Historical_Prices.py
CHANGED
|
@@ -1,7 +1,7 @@
|
|
| 1 |
import streamlit as st
|
| 2 |
import pandas as pd
|
| 3 |
import asyncio
|
| 4 |
-
|
| 5 |
import json
|
| 6 |
import io
|
| 7 |
import plotly.colors as pcolors
|
|
@@ -24,7 +24,7 @@ async def async_load_file_s3(object_key: str) -> pd.DataFrame:
|
|
| 24 |
"AWS credentials or bucket name not set in environment variables."
|
| 25 |
)
|
| 26 |
|
| 27 |
-
session =
|
| 28 |
async with session.create_client(
|
| 29 |
"s3",
|
| 30 |
aws_access_key_id=AWS_ACCESS_KEY_ID,
|
|
@@ -47,23 +47,23 @@ async def async_load_geojson_from_s3(object_key: str) -> dict:
|
|
| 47 |
with open(local_file_path, "r") as f:
|
| 48 |
return json.load(f)
|
| 49 |
|
| 50 |
-
session =
|
| 51 |
-
async with session.create_client(
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
) as s3_client:
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
|
| 68 |
|
| 69 |
@st.cache_resource
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
import pandas as pd
|
| 3 |
import asyncio
|
| 4 |
+
from aiobotocore.session import get_session # Corrected import
|
| 5 |
import json
|
| 6 |
import io
|
| 7 |
import plotly.colors as pcolors
|
|
|
|
| 24 |
"AWS credentials or bucket name not set in environment variables."
|
| 25 |
)
|
| 26 |
|
| 27 |
+
session = get_session() # Corrected usage
|
| 28 |
async with session.create_client(
|
| 29 |
"s3",
|
| 30 |
aws_access_key_id=AWS_ACCESS_KEY_ID,
|
|
|
|
| 47 |
with open(local_file_path, "r") as f:
|
| 48 |
return json.load(f)
|
| 49 |
|
| 50 |
+
# session = get_session() # Corrected usage
|
| 51 |
+
# async with session.create_client(
|
| 52 |
+
# "s3",
|
| 53 |
+
# aws_access_key_id=AWS_ACCESS_KEY_ID,
|
| 54 |
+
# aws_secret_access_key=AWS_SECRET_ACCESS_KEY,
|
| 55 |
+
# ) as s3_client:
|
| 56 |
+
# response = await s3_client.get_object(Bucket=AWS_S3_BUCKET, Key=object_key)
|
| 57 |
+
# status = response.get("ResponseMetadata", {}).get("HTTPStatusCode")
|
| 58 |
+
|
| 59 |
+
# if status == 200:
|
| 60 |
+
# async with response["Body"] as stream:
|
| 61 |
+
# content = await stream.read()
|
| 62 |
+
# os.makedirs(os.path.dirname(local_file_path), exist_ok=True)
|
| 63 |
+
# with open(local_file_path, "wb") as f:
|
| 64 |
+
# f.write(content)
|
| 65 |
+
# return json.loads(content.decode("utf-8"))
|
| 66 |
+
# raise ValueError(f"Unsuccessful S3 get_object response. Status - {status}")
|
| 67 |
|
| 68 |
|
| 69 |
@st.cache_resource
|