supereeg icon indicating copy to clipboard operation
supereeg copied to clipboard

set_context function

Open andrewheusser opened this issue 8 years ago • 3 comments

seaborn has a nice way to set the plot styling for a particular context (like figures for a talk, poster, paper or notebook)

I was thinking we could take a similar approach with superEEG, setting a context to run the code on a single computer, cluster, or some other setups. I idea would be to:

import superEEG
superEEG.set_context('google-cluster')

This would change an internal config object that determines the behavior of our functions (how the jobs are split up etc). thoughts?

andrewheusser avatar May 11 '17 11:05 andrewheusser

That a great idea! I like it.

jeremymanning avatar May 11 '17 12:05 jeremymanning

Here's how I currently have it implemented. Example code:

import superEEG

# print default context
print(superEEG.context)

# change context to preset cluster default
superEEG.set_context('cluster')

# print updated context
print(superEEG.context)

# change context to custom dict
google_cluster = {
    'environment' : 'google-cluster',
    'nodes' : 1000000000,
    'memory' : 3000000000,
}
superEEG.set_context(google_cluster)
print(superEEG.context)

Result:

{'environment': 'single', 'nodes': 1, 'memory': 8}
{'environment': 'cluster', 'nodes': 4, 'memory': 30}
{'environment': 'google-cluster', 'nodes': 1000000, 'memory': 3000000000}

We can then use this module attribute to make decisions. What do you think of this setup? What other attributes should we add to this dict?

andrewheusser avatar May 12 '17 12:05 andrewheusser

Job submission command, code directory, scratch directory, data directory, and probably others as we go...

jeremymanning avatar May 12 '17 12:05 jeremymanning