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

Fixes and qol features #26

Merged
merged 22 commits into from
Aug 31, 2018
Merged

Fixes and qol features #26

merged 22 commits into from
Aug 31, 2018

Conversation

FFroehlich
Copy link
Contributor

No description provided.

# fails this should not be caught right?

try:
import pandas as pd
Copy link
Member

Choose a reason for hiding this comment

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

I would rather put pandas in setup.py -> install_requires (might have missed that), and avoid try here, since it will be needed in many places anyway

@codecov-io
Copy link

codecov-io commented Aug 29, 2018

Codecov Report

Merging #26 into master will increase coverage by 2.42%.
The diff coverage is 83.15%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #26      +/-   ##
==========================================
+ Coverage   80.52%   82.94%   +2.42%     
==========================================
  Files          13       13              
  Lines         457      604     +147     
==========================================
+ Hits          368      501     +133     
- Misses         89      103      +14
Impacted Files Coverage Δ
pypesto/optimize/optimize.py 69.23% <45.45%> (-14.11%) ⬇️
pypesto/optimize/optimizer.py 87.5% <83.33%> (-2.98%) ⬇️
pypesto/objective.py 77.24% <86.4%> (+10.25%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d982b56...1bf69c2. Read the comment docs.

return sres

"""
Gradient checker function
Copy link
Member

Choose a reason for hiding this comment

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

could you describe in more detail what the function does?

@@ -81,6 +80,18 @@ def __init__(self, fun,
self.res = res
self.sres = sres

self.dim = dim
Copy link
Member

Choose a reason for hiding this comment

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

we had discussed with Jan to have dim only in the problem description, because sometimes an objective can be called with different argument lengths, and because we have this whole fixed parameters stuff. i am currently also working on sth related, and introduced in Problem a full_dim and a dim field which can be filled in diverse ways.
would there be a reason to have dim in objective with amici?

self.temp_file = None
self.temp_save_iter = None

def update_eval_counts(self, sensi_orders):
Copy link
Member

Choose a reason for hiding this comment

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

nice solution. i was wondering whether it would be possible to move this "counting stuff" to a wrapper class, so as to disentangle the objective and gradient computation from the counting part. the wrapping could then occur before every local optimization, also helping avoid parallelization and history issues.
but that can still be done later.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, we could push all the newly introduced fields to a different class but I do not see a way around attaching that class to the objective. But maybe there is some python magic that I do not know of.

Regarding parallelization, I think really the best way to do this is have pypesto being started from separate jobs. This is the only way to effectively parallelize across nodes on a cluster and also works on a local machine.
It would not work with cooperative scatter search strategies, but there we probably want to introduce an additional level of hierarchy anyways.

Copy link
Member

Choose a reason for hiding this comment

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

nice solution. i was wondering whether it would be possible to move this "counting stuff" to a wrapper class, so as to disentangle the objective and gradient computation from the counting part.

Using decorators?

Regarding parallelization, I think really the best way to do this is have pypesto being started from separate jobs

what do you mean by separate jobs?

Copy link
Member

Choose a reason for hiding this comment

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

Jan also mentioned that we would like to have transparent parallelization engines in optimization and sampling à-la pyabc using e.g. redis-servers, much of which one might be able to re-use. in optimization first of all I guess only starts would be parallelized, but also startpoint selection.

Copy link
Contributor Author

@FFroehlich FFroehlich Aug 31, 2018

Choose a reason for hiding this comment

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

what do you mean by separate jobs?

submitting individual batch jobs for every individual (subbatch of) optimization(s). e.g. using snakemake:

rule parameter_estimation:
	input:
		model=rules.build_amici.output,
		data=rules.process_data.output,
		script='parameter_estimation.py',
	output:
		os.path.join('results', 'multistart', '{modelname}', 'result_{dataset}_{repeat}.pickle')
	wildcard_constraints:
		modelname='[\w\d_]+',
		dataset='[\w\d]+',
		repeat='\d+'
	shell:
		expand('python3 {{input.script}} {{input.model}} {{wildcards.dataset}} {{wildcards.repeat}} {n_starts}', n_starts=MS_PER_JOB)[0]

This should fit with the notion of using redis servers. I would not recommend implementing threading or anything of that sorts in pypesto.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Wait, in pyABC you probably parallelized on the level to objective function calls and not on the level of optimization runs. This of course helps with load balancing but may result in overhead when submitting millions of tiny jobs for simpler models.

@ICB-DCM ICB-DCM deleted a comment Aug 31, 2018
@ICB-DCM ICB-DCM deleted a comment Aug 31, 2018
@ICB-DCM ICB-DCM deleted a comment Aug 31, 2018
@ICB-DCM ICB-DCM deleted a comment Aug 31, 2018
@ICB-DCM ICB-DCM deleted a comment Aug 31, 2018
@ICB-DCM ICB-DCM deleted a comment Aug 31, 2018
@ICB-DCM ICB-DCM deleted a comment Aug 31, 2018
@ICB-DCM ICB-DCM deleted a comment Aug 31, 2018
@ICB-DCM ICB-DCM deleted a comment Aug 31, 2018
@ICB-DCM ICB-DCM deleted a comment Aug 31, 2018
self.temp_file = None
self.temp_save_iter = None

def update_eval_counts(self, sensi_orders):
Copy link
Member

Choose a reason for hiding this comment

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

nice solution. i was wondering whether it would be possible to move this "counting stuff" to a wrapper class, so as to disentangle the objective and gradient computation from the counting part.

Using decorators?

Regarding parallelization, I think really the best way to do this is have pypesto being started from separate jobs

what do you mean by separate jobs?

pypesto/objective.py Show resolved Hide resolved
pypesto/objective.py Show resolved Hide resolved
@@ -244,12 +453,35 @@ class AmiciObjective(Objective):

def __init__(self, amici_model, amici_solver, edata, max_sensi_order=None,
preprocess_edata=True):
if 'amici' not in sys.modules:
if amici is None:
print('This objective requires an installation of amici ('
Copy link
Member

Choose a reason for hiding this comment

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

raise instead of print? No need to continue until we fail accessing amici. Maybe also better to keep everything amici-dependent in a separate file.

err
)
else:
optimizer_result = optimizer.minimize(problem, startpoint, j)
Copy link
Member

Choose a reason for hiding this comment

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

Avoid duplicate call to optimizer.minimize:

try: ...
except:
  if allow_failed_starts: ..
  else: rethrow

?

@ICB-DCM ICB-DCM deleted a comment Aug 31, 2018
@FFroehlich FFroehlich merged commit e149ca6 into master Aug 31, 2018
@FFroehlich FFroehlich deleted the fixes_qol_features branch August 31, 2018 17:22
suite.addTest(test_sbml_conversion.OptimizerTest())
suite.addTest(test_sbml_conversion.AmiciObjectiveTest())
suite.addTest(test_objective.ObjectiveTest())
suite.addTest(test_optimize.OptimizerTest())
testRunner = unittest.TextTestRunner(verbosity=0)
result = testRunner.run(suite)
Copy link
Member

Choose a reason for hiding this comment

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

is code_coverage still used? on travis coverage should be done automatically in https://github.com/ICB-DCM/pyPESTO/blob/master/.travis.yml#L39, afaio.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You are right, could you please delete the file in your PR?

@FFroehlich FFroehlich restored the fixes_qol_features branch September 5, 2018 14:21
@FFroehlich FFroehlich deleted the fixes_qol_features branch September 5, 2018 14:21
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