Esempio n. 1
0
def _check_version(hparams, logger, package="MultiPlanarUNet"):
    from MultiPlanarUNet.bin.version import VersionController
    vc = VersionController(package=package)
    if not vc.check_git():
        logger.warn(
            "Path {} does not contain a Git repository, or Git is not"
            " installed on this system.\n-- The software verison match "
            "could not be varified against the hyperparameter file.\n"
            "-- Software version will not be added to the "
            "hyperparameter file.".format(vc.git_path))
        return False
    if "__VERSION__" not in hparams:
        e = "Could not infer the software version used to produce the " \
            "hyperparameter file of this project. Using a later " \
            "version of the {} software on this project " \
            "may produce unexpected results. If you wish to continue " \
            "using this software version on this project dir, " \
            "manually add the following line to the hyperparameter file:" \
            " \n\n__VERSION__: {}\n".format(package, vc.version)
        logger.warn(e)
        raise RuntimeWarning(e)
    hp_version = hparams["__VERSION__"]
    if isinstance(hp_version, str) and vc.version != hp_version:
        e = "Parameter file indicates that this project was created " \
            "under {} version {}, but the current " \
            "version is {}. If you wish to continue " \
            "using this software version on this project dir, " \
            "manually add the following line to the hyperparameter " \
            "file:\n\n__VERSION__: {}\n".format(package, hp_version,
                                                vc.version, vc.version)
        logger.warn(e)
        raise RuntimeWarning(e)
    return True
Esempio n. 2
0
def _set_version(hparams, logger=None, package="MultiPlanarUNet"):
    from MultiPlanarUNet.bin.version import VersionController
    vc = VersionController(package=package)
    if logger:
        vc.log_version(logger)
    v, b, c = vc.version, vc.branch, vc.current_commit
    hparams.set_value(None, "__VERSION__", v, overwrite=True)
    hparams.set_value(None, "__BRANCH__", b, overwrite=True)
    hparams.set_value(None, "__COMMIT__", c, overwrite=True)
    hparams.save_current()
Esempio n. 3
0
def _set_version(hparams, logger=None):
    from MultiPlanarUNet.bin.version import VersionController
    vc = VersionController()
    if logger:
        vc.log_version(logger)
    v, b, c = vc.version, vc.branch, vc.current_commit
    hparams.set_value(None, "__VERSION__", v)
    hparams.set_value(None, "__BRANCH__", b)
    hparams.set_value(None, "__COMMIT__", c)
    hparams.save_current()