Skip to content

Commit f68f6e9

Browse files
committed
fix version pins
1 parent 1703d5c commit f68f6e9

File tree

11 files changed

+826
-20
lines changed

11 files changed

+826
-20
lines changed

Dockerfile

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# This sets up the container with Python 3.10 installed.
2+
FROM python:3.10-slim
3+
4+
# This copies everything in your current directory to the /app directory in the container.
5+
COPY . /app
6+
7+
# This sets the /app directory as the working directory for any RUN, CMD, ENTRYPOINT, or COPY instructions that follow.
8+
WORKDIR /app
9+
10+
# This runs pip install for all the packages listed in your requirements.txt file.
11+
RUN pip install -r requirements.txt
12+
13+
# This tells Docker to listen on port 80 at runtime. Port 80 is the standard port for HTTP.
14+
EXPOSE 8501
15+
16+
# # This command creates a .streamlit directory in the home directory of the container.
17+
# RUN mkdir ~/.streamlit
18+
19+
# # This copies your Streamlit configuration file into the .streamlit directory you just created.
20+
# RUN cp config.toml ~/.streamlit/config.toml
21+
22+
# Similar to the previous step, this copies your Streamlit credentials file into the .streamlit directory.
23+
# RUN cp credentials.toml ~/.streamlit/credentials.toml
24+
25+
# This sets the default command for the container to run the app with Streamlit.
26+
ENTRYPOINT ["streamlit", "run", "bw_timex_app/welcome.py"]
File renamed without changes.

bw_timex_app/cli.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@
33
import os
44

55
def main():
6-
app_path = os.path.join(os.path.dirname(__file__), "project_selection.py")
6+
app_path = os.path.join(os.path.dirname(__file__), "welcome.py")
77
subprocess.run([sys.executable, "-m", "streamlit", "run", app_path])

bw_timex_app/pages/calculate.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
)
2424

2525
if "current_project" not in st.session_state:
26-
st.switch_page("project_selection.py")
26+
st.switch_page("pages/project_selection.py")
2727

2828
bd.projects.set_current(st.session_state.current_project)
2929

@@ -263,16 +263,15 @@ def plot_characterized_inventory(tlca, **kwargs):
263263

264264
def custom_convert_to_datetime(x):
265265
if x == "dynamic":
266-
return x
267-
else:
268-
return datetime.strptime(x, "%Y-%m-%d")
269-
270-
database_date_dict = dict(
271-
zip(
272-
editor["Database"],
273-
editor["Representative Date"].apply(custom_convert_to_datetime),
274-
)
275-
)
266+
return x # Return as string
267+
try:
268+
return datetime.strptime(x, "%Y-%m-%d") # Convert to datetime
269+
except ValueError:
270+
raise ValueError(f"Invalid date format or value: {x}") # Raise error for invalid strings
271+
272+
representative_dates = editor["Representative Date"].apply(custom_convert_to_datetime)
273+
database_date_dict = {db_name: date for db_name, date in zip(editor["Database"], representative_dates)}
274+
276275
with st.status("Crunching the Numbers..."):
277276
st.write("Initializing TimexLCA")
278277
tlca = TimexLCA(
@@ -282,6 +281,7 @@ def custom_convert_to_datetime(x):
282281
)
283282
st.write("Building the Timeline")
284283
timeline = tlca.build_timeline()
284+
timeline
285285
st.write("Calculating time-explicit LCI")
286286
tlca.lci()
287287
st.write("Done!")

bw_timex_app/pages/mode.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
)
77

88
if "current_project" not in st.session_state:
9-
st.switch_page("project_selection.py")
9+
st.switch_page("pages/project_selection.py")
1010

1111
_, col, _ = st.columns([1, 2, 1])
1212
with col:

bw_timex_app/project_selection.py renamed to bw_timex_app/pages/project_selection.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ def add_timex_getting_started_project():
108108
def add_timex_ev_example_project():
109109
if "timex_ev_example" in bd.projects:
110110
bd.projects.delete_project("timex_ev_example", delete_dir=True)
111+
bd.projects.purge_deleted_directories()
111112
bd.projects.set_current("timex_ev_example")
112113
biosphere = bd.Database("biosphere")
113114
biosphere.write(
@@ -315,10 +316,10 @@ def add_timex_ev_example_project():
315316
add_timex_getting_started_project()
316317
# if "timex_ev_example" not in bd.projects:
317318
add_timex_ev_example_project()
318-
319+
319320
_, col, _ = st.columns([1, 2, 1])
320321
with col:
321-
st.title("Select a Project")
322+
st.subheader("Select a Project")
322323
st.text("")
323324
project_names = [
324325
project.name for project in bd.projects

bw_timex_app/pages/temporalize.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646

4747

4848
if "current_project" not in st.session_state:
49-
st.switch_page("project_selection.py")
49+
st.switch_page("pages/project_selection.py")
5050

5151

5252
def identify_activity_type(activity):

bw_timex_app/welcome.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import streamlit as st
2+
3+
st.set_page_config(
4+
page_title="bw_timex_app", layout="centered", initial_sidebar_state="collapsed"
5+
)
6+
7+
st.markdown("""
8+
<style>
9+
a[href] {
10+
text-decoration: underline;
11+
color: #9c5ffd;
12+
}
13+
</style>
14+
""", unsafe_allow_html=True)
15+
16+
_, col_welcome, _ = st.columns([1, 5, 1])
17+
with col_welcome:
18+
st.title(" Welcome ⏳🌿")
19+
st.write("This is the `bw_timex` web app. Here, you can temporalize your data, calculate time-explicit LCAs and interactively investigate the results.")
20+
st.write("")
21+
st.write("To learn more about the `bw_timex` package, check out our [docs](https://docs.brightway.dev/projects/bw-timex/en/latest/). The source code for this app is availabe [on GitHub](https://github.com/TimoDiepers/bw_timex_app).")
22+
st.write("")
23+
24+
if st.button("Get Started", use_container_width=True, type="primary"):
25+
st.switch_page("pages/project_selection.py")

conda/meta.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ requirements:
2525
- setuptools
2626
run:
2727
- python >=3.9
28-
- bw_timex >=0.2.6
28+
- bw_timex ==0.2.6
2929
- bw2io >=0.9.dev38
3030
- bw2data >=4.0.dev56
3131
- streamlit >=1.38.0
@@ -48,9 +48,9 @@ build:
4848
- archive/*
4949

5050
entry_points:
51-
- bw-timex = bw_timex_app.cli:main
51+
- timex-app = bw_timex_app.cli:main
5252

5353
files:
5454
include:
5555
- bw_timex_app/**
56-
- ../.streamlit/**
56+
- bw_timex_app/.streamlit/**

0 commit comments

Comments
 (0)