Skip to content

Commit

Permalink
page configurations
Browse files Browse the repository at this point in the history
  • Loading branch information
chiang-yuan committed Jun 26, 2024
1 parent 175ef10 commit 056d8d3
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 12 deletions.
5 changes: 2 additions & 3 deletions mlip_arena/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,8 @@
from torch import nn
from torch_geometric.data import Data

with open(os.path.join(os.path.dirname(__file__), "registry.yaml")) as f:
REGISTRY = yaml.load(f, Loader=yaml.FullLoader)

with open(Path(__file__).parent / "registry.yaml") as f:
REGISTRY = yaml.safe_load(f)

class MLIP(
nn.Module,
Expand Down
14 changes: 7 additions & 7 deletions mlip_arena/tasks/__init__.py
Original file line number Diff line number Diff line change
@@ -1,25 +1,26 @@
import os
from pathlib import Path

import yaml
from huggingface_hub import HfApi, HfFileSystem, hf_hub_download

from mlip_arena.models import MLIP
from mlip_arena.models import REGISTRY as MODEL_REGISTRY

with open(os.path.join(os.path.dirname(__file__), "registry.yaml")) as f:
REGISTRY = yaml.load(f, Loader=yaml.FullLoader)
with open(Path(__file__).parent / "registry.yaml") as f:
REGISTRY = yaml.safe_load(f)


class Task:
def __init__(self):
self.name: str = self.__class__.__name__ # display name on the leaderboard

def run_local(self, model: MLIP):
"""Run the task using the given model and return the results"""
"""Run the task using the given model and return the results."""
raise NotImplementedError

def run_hf(self, model: MLIP):
"""Run the task using the given model and return the results"""
"""Run the task using the given model and return the results."""
raise NotImplementedError

# Calcualte evaluation metrics and postprocessed data
Expand All @@ -32,12 +33,11 @@ def run_hf(self, model: MLIP):
)

def run_nersc(self, model: MLIP):
"""Run the task using the given model and return the results"""
"""Run the task using the given model and return the results."""
raise NotImplementedError

def get_results(self):
"""Get the results from the task"""

"""Get the results from the task."""
# fs = HfFileSystem()
# files = fs.glob(f"datasets/atomind/mlip-arena/{self.__class__.__name__}/*/*.json")

Expand Down
64 changes: 62 additions & 2 deletions serve/app.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,64 @@
import streamlit as st

x = st.slider("Select a value")
st.write(x, "squared is", x * x)
# Assuming you have similar modules as in the example
# For demonstration, these functions will be defined here directly
def home_page():
st.title("Home Page")
st.write("Welcome to the Home Page!")

def analytics_page():
st.title("Analytics Page")
st.write("Analytics details go here.")

def settings_page():
st.title("Settings Page")
st.write("Settings details go here.")

# Mimicking the page_group utility from the example
class PageGroup:
def __init__(self, key):
self.key = key
self.pages = {}
self.default_page = None

def item(self, title, func, default=False):
self.pages[title] = func
if default:
self.default_page = title

def show(self):
# Use session state to remember the current page
if 'current_page' not in st.session_state or st.session_state.current_page not in self.pages:
st.session_state.current_page = self.default_page

# Display the current page function
self.pages[st.session_state.current_page]()

def main():
page = PageGroup("p")

with st.sidebar:
st.title("Navigation")

with st.expander("Pages", True):
for title, func in [("Home", home_page), ("Analytics", analytics_page), ("Settings", settings_page)]:

if st.button(title):
st.session_state.current_page = title

page.item("Home", home_page, default=True)
page.item("Analytics", analytics_page)
page.item("Settings", settings_page)

page.show()

if __name__ == "__main__":
# st.set_page_config(page_title="My Streamlit App", page_icon="📊", layout="wide")
st.set_page_config(
layout="wide",
page_title="MLIP Arena",
page_icon=":shark:",
# initial_sidebar_state="expanded",
menu_items=None
)
main()

0 comments on commit 056d8d3

Please sign in to comment.