Skip to content

Commit

Permalink
ModelExplorer: sidebar, limited text #232
Browse files Browse the repository at this point in the history
  • Loading branch information
glebbelov committed Mar 19, 2024
1 parent c13addb commit 9693f72
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 11 deletions.
2 changes: 1 addition & 1 deletion include/mp/flat/constr_keeper.h
Original file line number Diff line number Diff line change
Expand Up @@ -928,7 +928,7 @@ class ConstraintKeeper final
}
/// Export constraint status.
/// This is called in the end,
/// so printing the readbale form.
/// so printing the readable form.
void ExportConStatus(int i_con, const Container& cnt,
const std::vector<std::string>* pvnam) {
if (GetLogger()) {
Expand Down
3 changes: 1 addition & 2 deletions src/problem.cc
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,7 @@ const std::string& BasicProblem<Params>::item_name(
bool fbr = '['==stub[l-1];
names[k] = stub;
names[k] += std::to_string(k-k_sub+1);
if (fbr)
names[k] += ']';
names[k] += (fbr ? ']' : '_');
}
};
if (n2>=0 && n2<n) {
Expand Down
20 changes: 12 additions & 8 deletions support/modelexplore/modelexplore.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,16 @@
# To work with local files in st 1.30.1, see
# https://discuss.streamlit.io/t/axioserror-request-failed-with-status-code-403/38112/13.
# The corresponding settings should not be used on a server.
uploader = st.file_uploader("Model file (JSONL)")

left_column, right_column = st.columns(2)
uploader = st.sidebar.file_uploader("Model file (JSONL)")

# You can use a column just like st.sidebar:
srch = left_column.text_input('Search pattern:')
srch = st.sidebar.text_input('Search pattern:')

fwd = st.sidebar.checkbox('Add descendants', disabled=True)
bwd = st.sidebar.checkbox('Add ancestors', disabled=True)

left_column, right_column = st.columns(2)

fwd = right_column.checkbox('Add descendants', disabled=True)
bwd = right_column.checkbox('Add ancestors', disabled=True)

# Cache the reading function
@st.cache_data
Expand All @@ -30,8 +31,11 @@ def MatchSelection(m, srch, fwd, bwd):
# Write dictionary of entries
def WriteDict(d):
for k, v in d.items():
with st.expander("""### """ + k):
st.code(v, language='ampl')
if len(v):
with st.expander("""### """ + k + ' (' + \
str(v.count('\n')) + ')'):
with st.container(height=200):
st.code(v, language='ampl')

# Or even better, call Streamlit functions inside a "with" block:
if uploader is not None:
Expand Down

0 comments on commit 9693f72

Please sign in to comment.