mirror of
https://github.com/clearml/clearml-agent
synced 2025-02-12 07:38:04 +00:00
Fix avoid reinstall pytorch package if the same version is already installed
This commit is contained in:
parent
9c7e2aacd0
commit
6572023173
@ -318,12 +318,14 @@ class PytorchRequirement(SimpleSubstitution):
|
|||||||
from pip._internal.commands.show import search_packages_info
|
from pip._internal.commands.show import search_packages_info
|
||||||
installed_torch = list(search_packages_info([req.name]))
|
installed_torch = list(search_packages_info([req.name]))
|
||||||
# notice the comparison order, the first part will make sure we have a valid installed package
|
# notice the comparison order, the first part will make sure we have a valid installed package
|
||||||
if installed_torch and installed_torch[0]['version'] and \
|
installed_torch_version = (getattr(installed_torch[0], 'version', None) or installed_torch[0]['version']) \
|
||||||
req.compare_version(installed_torch[0]['version']):
|
if installed_torch else None
|
||||||
|
if installed_torch and installed_torch_version and \
|
||||||
|
req.compare_version(installed_torch_version):
|
||||||
print('PyTorch: requested "{}" version {}, using pre-installed version {}'.format(
|
print('PyTorch: requested "{}" version {}, using pre-installed version {}'.format(
|
||||||
req.name, req.specs[0] if req.specs else 'unspecified', installed_torch[0]['version']))
|
req.name, req.specs[0] if req.specs else 'unspecified', installed_torch_version))
|
||||||
# package already installed, do nothing
|
# package already installed, do nothing
|
||||||
req.specs = [('==', str(installed_torch[0]['version']))]
|
req.specs = [('==', str(installed_torch_version))]
|
||||||
return '{} {} {}'.format(req.name, req.specs[0][0], req.specs[0][1]), True
|
return '{} {} {}'.format(req.name, req.specs[0][0], req.specs[0][1]), True
|
||||||
except Exception:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
|
Loading…
Reference in New Issue
Block a user