"src/tl_templates/cpp/common.h" did not exist on "3486e27e1947698c2625ce85d95d8dfb79304b24"
Unverified Commit d10b8bca authored by SparkSnail's avatar SparkSnail Committed by GitHub
Browse files

Fix version check (#906)

There is one kind of version string like 'v0.5.2-gews11f', it is generated by installing from source code.
In current trialKeeper, use exact version match, and this version string will cause code break in msranni/nni image, because our offical image use clean number version.
Change the logic to fuzzy match, only match the main number of nni.
parent e42137a8
......@@ -109,22 +109,25 @@ def check_version(args):
trial_keeper_version = pkg_resources.get_distribution('nni').version
except pkg_resources.ResolutionError as err:
#package nni does not exist, try nni-tool package
nni_log(LogType.Warning, 'Package nni does not exist!')
try:
trial_keeper_version = pkg_resources.get_distribution('nni-tool').version
except pkg_resources.ResolutionError as err:
#package nni-tool does not exist
nni_log(LogType.Error, 'Package nni-tool does not exist!')
nni_log(LogType.Error, 'Package nni does not exist!')
os._exit(1)
if not args.version:
# skip version check
nni_log(LogType.Warning, 'Skipping version check!')
elif trial_keeper_version != args.version:
nni_log(LogType.Error, 'Exit trial keeper, trial keeper version is {}, and trainingService version is {}, \
versions does not match, please check your code and image versions!'.format(trial_keeper_version, args.version))
else:
regular = re.compile('v?(?P<version>[0-9](\.[0-9]){0,2}).*')
try:
trial_keeper_version = regular.search(trial_keeper_version).group('version')
nni_log(LogType.Info, 'trial_keeper_version is {0}'.format(trial_keeper_version))
training_service_version = regular.search(args.version).group('version')
nni_log(LogType.Info, 'training_service_version is {0}'.format(training_service_version))
if trial_keeper_version != training_service_version:
nni_log(LogType.Error, 'Version does not match!')
os._exit(1)
else:
nni_log(LogType.Info, 'NNI version is {}'.format(args.version))
nni_log(LogType.Info, 'Version match!')
except AttributeError as err:
nni_log(LogType.Error, err)
if __name__ == '__main__':
'''NNI Trial Keeper main function'''
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment