Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UI layout #1825

Closed
wants to merge 5 commits into from
Closed

UI layout #1825

wants to merge 5 commits into from

Conversation

ankitk50
Copy link
Contributor

This PR will focus on changes to the UI layout. Below is the initial proposal.

Screenshot 2023-09-26 at 15 57 57

@Corvince
Copy link
Contributor

Ha, funny, I was experimenting today with the exact same ideas. The only change I would suggest is putting the controls into the main area and not the sidebar. On small screens and thus often in Notebooks the sidebar is collapsed by default and doesn't stay open, so this makes it hard to control the model.

But otherwise this is very nice 👍

solara.Markdown(name)
UserInputs(user_params, on_change=handle_change_model_params)
ModelController(model, play_interval, current_step, set_current_step, reset_counter)
with solara.AppBarTitle():
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
with solara.AppBarTitle():
solara.Title(name)

This also sets the tab title

@ankitk50
Copy link
Contributor Author

ankitk50 commented Oct 3, 2023

I have added a check that allows us to identify Jupyter from normal. And based on this we can change the UI layout.

import mesa

# Avoid interactive backend
plt.switch_backend("agg")
plt.rcParams["figure.figsize"] = (7, 7)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You shouldn't set the figure size globally, because this affects both the space/grid and the plots. Needs to be more fine-grained. This comments applies to #1820 as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will resolve this by tomorrow, thanks for pointing this out

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I need an explanation on why this hasn't been acted on in 3 weeks.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this has been removed

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know. It took 3 weeks. What is the explanation?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

at the moment -- No.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm aware of #1821, it's just that I feel it would be much easier to build upon when #1825 merged and stable.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same with #1820. It will become irrelevant after #1825 is merged. Scaling happens automatically.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#1821 is simple to implement, orthogonal to your existing 2 PRs. Waiting for #1825 is not a sufficient justification for not working on it. If you don't want to do it, please say sooner. It is a needed feature that needs to be delivered soon. I will just do it.

#1820 is needed because this PR only handles the total space visualization with, and doesn't fix the overlapping markers.

I am appalled by your responses here so far. No replies on #1820, then suddenly you decided to not work on it for a reason that you think it is irrelevant, and which it is not justifiable either.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am very sorry for my comments and the lack of understanding of how you allocate time for your workflow, given that you are busy with classes as well. It was uncalled for. I haven't said earlier that you should have communicated your thoughts that #1820 is unnecessary. But it would be great next time to tell this and so we can discuss about it. Thank you for what you have done so far, and hope we can get this done by CSSSA.

@ankitk50 ankitk50 marked this pull request as ready for review October 29, 2023 20:36
@codecov
Copy link

codecov bot commented Oct 30, 2023

Codecov Report

Attention: 61 lines in your changes are missing coverage. Please review.

Comparison is base (adc5549) 79.12% compared to head (c464a33) 78.27%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1825      +/-   ##
==========================================
- Coverage   79.12%   78.27%   -0.86%     
==========================================
  Files          15       17       +2     
  Lines         915      962      +47     
  Branches      194      214      +20     
==========================================
+ Hits          724      753      +29     
- Misses        168      183      +15     
- Partials       23       26       +3     
Files Coverage Δ
mesa/experimental/user_input.py 72.22% <72.22%> (ø)
mesa/experimental/jupyter_viz.py 38.69% <62.50%> (+8.52%) ⬆️
mesa/experimental/model_control.py 12.50% <12.50%> (ø)

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@tpike3
Copy link
Member

tpike3 commented Oct 30, 2023

@ankitk50 Thanks, very excited about these updates. To merge can you:

  • take a look at your lint and ruff failures please.
  • Also take a look at your commits and see if you can group/squash them into the key changes. The goal is a easily readable where the key changes are easily identifiable.

Again very cool. Excited to get this into mesa.


# render layout and plot

if "ipykernel" in sys.argv[0]: # jupyter
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you split the following if-else into 2 components each defined in a function?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

component forces re-render of Cards , for now I have moved these to two functions

@@ -281,7 +221,17 @@ def portray(g):
out["c"] = c
return out

space_ax.scatter(**portray(space))

# figure(figsize=(50, 50), dpi=80)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs to be removed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

introduced by automated merge, should be resolved


# figure(figsize=(50, 50), dpi=80)
space_fig = Figure()
space_ax = space_fig.subplots()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function already has space_ax in the argument, so these 2 lines are unnecessary.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Upon reading further, the whole new change from this line to L234 are duplicate of make_space. Please remove it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

introduced by automated merge, should be resolved

@rht
Copy link
Contributor

rht commented Oct 30, 2023

Also take a look at your commits and see if you can group/squash them into the key changes. The goal is a easily readable where the key changes are easily identifiable.

My feedback with the current PR is that I have to review line by line comparing with the old version, because there could be unexpected changes being slipped in. This is more time consuming that necessary. And indeed there are: #1825 (comment).

on_click=do_reset,
)

# with solara.Row(gap="10px", justify="center"):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is another line that needs to be removed.

@rht
Copy link
Contributor

rht commented Oct 30, 2023

I have found another line slipped in https://github.com/projectmesa/mesa/pull/1825/files#r1375915733, and having to review from scratch every line changed is taxing for me. Can you open a new PR that does the splitting of ModelController and UserInputs into separate files, and redo this PR cleanly over this atomic change once merged? There is enough time until CSSSA.

@ankitk50
Copy link
Contributor Author

I have found another line slipped in https://github.com/projectmesa/mesa/pull/1825/files#r1375915733, and having to review from scratch every line changed is taxing for me. Can you open a new PR that does the splitting of ModelController and UserInputs into separate files, and redo this PR cleanly over this atomic change once merged? There is enough time until CSSSA.

Sure

@ankitk50
Copy link
Contributor Author

The major changes related to the UI has been moved to #1854. I will create a separate PR for restructuring / reorganising.

@tpike3 tpike3 closed this Nov 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants