From 20e4df24a4470f66c4ccfec7be2cd39f47196ae7 Mon Sep 17 00:00:00 2001 From: EricGustin Date: Mon, 24 Jan 2022 14:44:21 -0800 Subject: [PATCH 1/4] Remove np from step.py and requirements Create a helper function called get_base_36_repr so that we can remove numpy from step.py Remove numpy from requirements.txt Pin requirements.dev to a specific version of numpy --- requirements-dev.txt | 2 +- requirements.txt | 1 - smartsim/_core/launcher/step/step.py | 4 ++-- smartsim/_core/utils/helpers.py | 18 ++++++++++++++++++ 4 files changed, 21 insertions(+), 4 deletions(-) diff --git a/requirements-dev.txt b/requirements-dev.txt index cff63d62c..cace3bc22 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -3,7 +3,7 @@ smartredis>=0.1.1 redis==3.5.3 redis-py-cluster==2.1.3 sphinx==3.1.1 -numpy>=1.18.2 +numpy~=1.19.2 tqdm>=4.50.2 psutil>=5.7.2 tabulate>=0.8.9 diff --git a/requirements.txt b/requirements.txt index 7f4b70491..874133d43 100644 --- a/requirements.txt +++ b/requirements.txt @@ -4,5 +4,4 @@ tabulate>=0.8.9 smartredis>=0.1.1 redis==3.5.3 redis-py-cluster==2.1.3 -numpy>=1.18.2 tqdm>=4.50.2 diff --git a/smartsim/_core/launcher/step/step.py b/smartsim/_core/launcher/step/step.py index fa574218d..9604e4bfd 100644 --- a/smartsim/_core/launcher/step/step.py +++ b/smartsim/_core/launcher/step/step.py @@ -27,7 +27,7 @@ import os.path as osp import time -import numpy as np +from ...utils.helpers import get_base_36_repr class Step: @@ -41,7 +41,7 @@ def get_launch_cmd(self): raise NotImplementedError def _create_unique_name(self, entity_name): - step_name = entity_name + "-" + str(np.base_repr(time.time_ns(), 36)) + step_name = entity_name + "-" + get_base_36_repr(time.time_ns()) return step_name def get_output_files(self): diff --git a/smartsim/_core/utils/helpers.py b/smartsim/_core/utils/helpers.py index 277d085d2..7b34f1af9 100644 --- a/smartsim/_core/utils/helpers.py +++ b/smartsim/_core/utils/helpers.py @@ -34,6 +34,24 @@ import psutil +def get_base_36_repr(positive_int): + """Converts a positive integer to its base 36 representation + :param positive_int: the positive integer to convert + :type positive_int: int + :return: base 36 representation of the given positive int + :rtype: str + """ + digits = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ' + result = [] + + while positive_int: + next_digit = digits[positive_int % 36] + result.append(next_digit) + positive_int //= 36 + + return ''.join(reversed(result)) + + def get_ip_from_host(host): """Return the IP address for the interconnect. From 423344fd5d3bdb3907a838d43ed585349370602f Mon Sep 17 00:00:00 2001 From: EricGustin Date: Wed, 26 Jan 2022 15:55:44 -0800 Subject: [PATCH 2/4] Remove numpy from requirements --- requirements-dev.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/requirements-dev.txt b/requirements-dev.txt index cace3bc22..c35d7c182 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -3,7 +3,6 @@ smartredis>=0.1.1 redis==3.5.3 redis-py-cluster==2.1.3 sphinx==3.1.1 -numpy~=1.19.2 tqdm>=4.50.2 psutil>=5.7.2 tabulate>=0.8.9 From b04ab87595bb515a42f43a83f73a38474b51dbab Mon Sep 17 00:00:00 2001 From: EricGustin Date: Wed, 26 Jan 2022 15:57:16 -0800 Subject: [PATCH 3/4] Remove numpy from setup --- setup.py | 1 - 1 file changed, 1 deletion(-) diff --git a/setup.py b/setup.py index b9e75673a..e10b02294 100644 --- a/setup.py +++ b/setup.py @@ -139,7 +139,6 @@ def has_ext_modules(_placeholder): "tabulate>=0.8.9", "redis-py-cluster==2.1.3", "redis==3.5.3", - "numpy>=1.18.2", "tqdm>=4.50.2" ] From 300cfb2281ef8f03be0ea093d71aa911cc49942f Mon Sep 17 00:00:00 2001 From: EricGustin Date: Wed, 26 Jan 2022 16:10:16 -0800 Subject: [PATCH 4/4] style --- smartsim/_core/utils/helpers.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/smartsim/_core/utils/helpers.py b/smartsim/_core/utils/helpers.py index 7b34f1af9..2c7cd632e 100644 --- a/smartsim/_core/utils/helpers.py +++ b/smartsim/_core/utils/helpers.py @@ -41,7 +41,7 @@ def get_base_36_repr(positive_int): :return: base 36 representation of the given positive int :rtype: str """ - digits = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ' + digits = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ" result = [] while positive_int: @@ -49,7 +49,7 @@ def get_base_36_repr(positive_int): result.append(next_digit) positive_int //= 36 - return ''.join(reversed(result)) + return "".join(reversed(result)) def get_ip_from_host(host):