Skip to content

Commit

Permalink
add refresh method to model packs
Browse files Browse the repository at this point in the history
  • Loading branch information
michi42 committed Jan 28, 2019
1 parent 9c64d70 commit f0a4fa7
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion pyjmad/modelpack.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def _repo_from_uri(uri):
repo = method.getName()
jmad_default_repositories[repo] = _repo_to_uri(getattr(_JMadModelRepositories, repo)())
except Exception:
logging.exception("can not fetch default models from jmad-modelpack-service")
logging.exception('can not fetch default models from jmad-modelpack-service')

class JMadModelPackService(object):
def __init__(self, applicationContext):
Expand All @@ -62,6 +62,11 @@ def modelpack_name(pkg):
for name, variants in itertools.groupby(modelpacks, modelpack_name):
self._modelpacks[name] = ModelPackType(self, name, variants)

def refresh(self):
logging.info('Clearing caches and reloading model packs ...')
self._javaService.clearCache().block()
self._reload()

@property
def repositories(self):
return [_repo_to_uri(r) for r in self._javaRepositoryManager.enabledRepositories().collectList().block()]
Expand Down

0 comments on commit f0a4fa7

Please sign in to comment.