From 428781af86668328f7a03a5fd8f73144eb252561 Mon Sep 17 00:00:00 2001 From: allegroai <> Date: Fri, 25 Dec 2020 02:06:40 +0200 Subject: [PATCH] Fix support for Windows pip and Conda requirements.txt --- clearml_agent/helper/package/base.py | 2 +- clearml_agent/helper/package/conda_api.py | 18 ++++++------------ 2 files changed, 7 insertions(+), 13 deletions(-) diff --git a/clearml_agent/helper/package/base.py b/clearml_agent/helper/package/base.py index 8a41934..feec39f 100644 --- a/clearml_agent/helper/package/base.py +++ b/clearml_agent/helper/package/base.py @@ -67,7 +67,7 @@ class PackageManager(object): def upgrade_pip(self): result = self._install( - select_for_platform(windows='"pip{}"', linux='pip{}').format(self.get_pip_version()), "--upgrade") + select_for_platform(windows='pip{}', linux='pip{}').format(self.get_pip_version()), "--upgrade") packages = self.run_with_env(('list',), output=True).splitlines() # p.split is ('pip', 'x.y.z') pip = [p.split() for p in packages if len(p.split()) == 2 and p.split()[0] == 'pip'] diff --git a/clearml_agent/helper/package/conda_api.py b/clearml_agent/helper/package/conda_api.py index 0eac20c..64656b4 100644 --- a/clearml_agent/helper/package/conda_api.py +++ b/clearml_agent/helper/package/conda_api.py @@ -132,7 +132,7 @@ class CondaAPI(PackageManager): if self.env_read_only: print('Conda environment in read-only mode, skipping pip upgrade.') return '' - return self._install(select_for_platform(windows='"pip{}"', linux='pip{}').format(self.pip.get_pip_version())) + return self._install(select_for_platform(windows='pip{}', linux='pip{}').format(self.pip.get_pip_version())) def create(self): """ @@ -284,17 +284,11 @@ class CondaAPI(PackageManager): """ Try to install packages from conda. Install packages which are not available from conda with pip. """ - try: - self._install_from_file(path) - return - except PackageNotFoundError as e: - pip_packages = [e.pkg] - except PackagesNotFoundError as e: - pip_packages = package_set(e.packages) - with self.temp_file("conda_reqs", _package_diff(path, pip_packages)) as reqs: - self.install_from_file(reqs) - with self.temp_file("pip_reqs", pip_packages) as reqs: - self.pip.install_from_file(reqs) + requirements = {} + # assume requirements.txt + with open(path, 'rt') as f: + requirements['pip'] = f.read() + self.load_requirements(requirements) def freeze(self, freeze_full_environment=False): requirements = self.pip.freeze()