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

Add some convenience to simulation creation. #1904

Merged

Conversation

thorstenhater
Copy link
Contributor

@thorstenhater thorstenhater commented Jun 9, 2022

Encapsulates 80% of cases:

 rec = recipe()
 ctx = make_context()
 dec = partition_load_balance(rec, ctx)
 sim = simulation(rec, dec, ctx)

is now written as

 rec = recipe()
 sim = simulation(rec)

In python we use keyword args to allow
both to be specified separatly.

Partially fixes #1862

Encapsulates 80% of cases:
```cxx
 rec = recipe()
 ctx = make_context()
 dec = partition_load_balance(rec, ctx)
 sim = simulation(rec, dec, ctx)
```
is now written as
```cxx
 rec = recipe()
 sim = simulation(rec)
```
In python we use keyword args to allow
both to be specified separatly.
Copy link
Collaborator

@Helveg Helveg left a comment

Choose a reason for hiding this comment

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

Nice! I checked only the Python impact

python/example/network_ring.py Outdated Show resolved Hide resolved
Copy link
Contributor

@brenthuisman brenthuisman left a comment

Choose a reason for hiding this comment

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

Noice, a few requests.

example/lfp/lfp.cpp Outdated Show resolved Hide resolved
python/example/network_ring.py Outdated Show resolved Hide resolved
python/example/single_cell_cable.py Show resolved Hide resolved
python/example/single_cell_recipe.py Show resolved Hide resolved
python/simulation.cpp Outdated Show resolved Hide resolved
arbor/include/arbor/load_balance.hpp Show resolved Hide resolved
example/brunel/brunel.cpp Outdated Show resolved Hide resolved
arbor/include/arbor/simulation.hpp Show resolved Hide resolved
example/dryrun/dryrun.cpp Show resolved Hide resolved
example/generators/generators.cpp Show resolved Hide resolved
Copy link
Collaborator

@Helveg Helveg left a comment

Choose a reason for hiding this comment

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

No objections 👍

Copy link
Contributor

@brenthuisman brenthuisman left a comment

Choose a reason for hiding this comment

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

Some minor things.

example/lfp/lfp.cpp Show resolved Hide resolved
example/ring/ring.cpp Show resolved Hide resolved
example/ring/ring.cpp Show resolved Hide resolved
decomp = arbor.partition_load_balance(recipe, context)
sim = arbor.simulation(recipe, decomp, context)
ctx = arbor.context("avail_threads")
sim = arbor.simulation(recipe, context=ctx)
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
sim = arbor.simulation(recipe, context=ctx)
sim = arbor.simulation(recipe, arbor.context("avail_threads"))

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Robin requested the exact opposite ;)

Copy link
Collaborator

@Helveg Helveg Jun 21, 2022

Choose a reason for hiding this comment

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

I'll argue my case:

  • If argument order changes, which it just did, using explicitly named arguments obviates refactoring on the call site.
  • It's more explicit, although arbor.context and the variable name ctx make it clear enough. It's not that WET either. You'll find many call sites have patterns like tree=tree, axe=axe, chop=chop

Copy link
Contributor

Choose a reason for hiding this comment

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

The main thing I care about is that as of The Swap(tm) context= can be left out. I'd have peace with

Suggested change
sim = arbor.simulation(recipe, context=ctx)
sim = arbor.simulation(recipe, ctx)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So, I'll let you two battle that out, I'd chosen @brenthuisman 's suggestion and only change due to Robin's wishes.
Less typing is almost always to be preferred.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Fine with me :)

python/example/network_ring_mpi.py Outdated Show resolved Hide resolved
python/example/single_cell_detailed_recipe.py Show resolved Hide resolved
@brenthuisman brenthuisman merged commit d15afd3 into arbor-sim:master Jun 21, 2022
brenthuisman added a commit to brenthuisman/arbor that referenced this pull request Jun 24, 2022
- Mention arbor-contrib in a few relevant places
- Correct some fallout from arbor-sim#1904
- A new hardware and profiling tutorial, and covers things moved out of other examples in arbor-sim#1904
- Various other documentation fixes
brenthuisman added a commit that referenced this pull request Jun 30, 2022
- Fix line numbers in tutorials, fallout from #1906
- Mention arbor-contrib in a few relevant places
- Correct some fallout from #1904
- A new hardware and profiling tutorial, and covers things moved out of other examples in #1904
- Various other documentation fixes
@thorstenhater thorstenhater deleted the convenience/simpler-load-balancing branch August 1, 2022 07:39
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.

Ergonomics
3 participants