From d4fb1b62314408015314a7a1f4970e8b9067ce5f Mon Sep 17 00:00:00 2001 From: ppinchuk Date: Wed, 31 Jul 2024 11:38:08 -0600 Subject: [PATCH 1/8] Fix typo --- examples/example_users.rst | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/examples/example_users.rst b/examples/example_users.rst index fe19959a..a06c6b2e 100644 --- a/examples/example_users.rst +++ b/examples/example_users.rst @@ -846,11 +846,11 @@ combinations into multiple sets in our batch config: "sets": [ { "args": { - "wind_turbine_hub_ht": [100], + "wind_turbine_hub_ht": [110], "wind_turbine_rotor_diameter": [145, 170] }, "files": ["./turbine.json"], - "set_tag": "100hh" + "set_tag": "110hh" }, { "args": { @@ -869,7 +869,7 @@ Now if we run batch (``--dry``), we will only get three sub-directories, which i shell $ ls - 100hh_wtrd145 100hh_wtrd170 120hh_wtrd160 batch_jobs.csv config_batch.json config_gen.json config_pipeline.json turbine.json + 110hh_wtrd145 110hh_wtrd170 120hh_wtrd160 batch_jobs.csv config_batch.json config_gen.json config_pipeline.json turbine.json Note how we used the ``"set_tag"`` key to get consistent names across the newly-created runs. Once again, we can verify that batch correctly updated the parameters in each sub-directory: @@ -878,21 +878,21 @@ we can verify that batch correctly updated the parameters in each sub-directory: .. code-block:: shell - $ cat 100hh_wtrd145/turbine.json + $ cat 110hh_wtrd145/turbine.json { ... "wind_turbine_rotor_diameter": 145, ... - "wind_turbine_hub_ht": 100, + "wind_turbine_hub_ht": 110, ... } - $ cat 100hh_wtrd170/turbine.json + $ cat 110hh_wtrd170/turbine.json { ... "wind_turbine_rotor_diameter": 170, ... - "wind_turbine_hub_ht": 100, + "wind_turbine_hub_ht": 110, ... } From 03e0150283cd3e3d0536120df5af0e6f0606dfe1 Mon Sep 17 00:00:00 2001 From: ppinchuk Date: Wed, 31 Jul 2024 11:39:11 -0600 Subject: [PATCH 2/8] Update docstring --- tests/cli/test_cli_documentation.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/cli/test_cli_documentation.py b/tests/cli/test_cli_documentation.py index 4e97441b..5310ed84 100644 --- a/tests/cli/test_cli_documentation.py +++ b/tests/cli/test_cli_documentation.py @@ -491,7 +491,7 @@ def _func(another_param, d=42, e=None): def test_command_documentation_for_class(): - """Test `CommandDocumentation` with func missing docstring.""" + """Test `CommandDocumentation` for a mix of classes and functions.""" class TestCommand: """A test command as a class.""" From abbeec4cecc4604f0cc3da69f75060c6fa58ed1d Mon Sep 17 00:00:00 2001 From: ppinchuk Date: Wed, 31 Jul 2024 11:45:37 -0600 Subject: [PATCH 3/8] Rename `parameter_help` -> `hpc_parameter_help` for clarity --- gaps/cli/documentation.py | 4 ++-- tests/cli/test_cli_config.py | 6 +++--- tests/cli/test_cli_documentation.py | 14 +++++++------- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/gaps/cli/documentation.py b/gaps/cli/documentation.py index b242dc59..c950cf63 100644 --- a/gaps/cli/documentation.py +++ b/gaps/cli/documentation.py @@ -502,7 +502,7 @@ def template_config(self): return config @property - def parameter_help(self): + def hpc_parameter_help(self): """str: Parameter help for the func, including execution control.""" exec_dict_param = [ p @@ -557,7 +557,7 @@ def config_help(self, command_name): doc = CONFIG_DOC.format( name=command_name, sample_config=sample_config, - docstring=self.parameter_help, + docstring=self.hpc_parameter_help, ) return _cli_formatted(doc) diff --git a/tests/cli/test_cli_config.py b/tests/cli/test_cli_config.py index fa6497ab..3d1cf25f 100644 --- a/tests/cli/test_cli_config.py +++ b/tests/cli/test_cli_config.py @@ -1113,13 +1113,13 @@ def test_command_skip_doc_params(test_class): skip_doc_params={"input1"}, ) - assert "input1" not in command_config.documentation.parameter_help + assert "input1" not in command_config.documentation.hpc_parameter_help assert "input1" not in command_config.documentation.template_config - assert "_input2" not in command_config.documentation.parameter_help + assert "_input2" not in command_config.documentation.hpc_parameter_help assert "_input2" not in command_config.documentation.template_config - assert "input3" in command_config.documentation.parameter_help + assert "input3" in command_config.documentation.hpc_parameter_help assert "input3" in command_config.documentation.template_config diff --git a/tests/cli/test_cli_documentation.py b/tests/cli/test_cli_documentation.py index 5310ed84..9bfdf4b4 100644 --- a/tests/cli/test_cli_documentation.py +++ b/tests/cli/test_cli_documentation.py @@ -332,8 +332,8 @@ def func(project_points, a, max_workers, b=1, c=None): assert doc.template_config == expected_config -def test_command_documentation_parameter_help(): - """Test `CommandDocumentation.parameter_help`.""" +def test_command_documentation_hpc_parameter_help(): + """Test `CommandDocumentation.hpc_parameter_help`.""" def func(project_points): """Test func. @@ -345,7 +345,7 @@ def func(project_points): """ doc = CommandDocumentation(func, is_split_spatially=True) - param_help = doc.parameter_help + param_help = doc.hpc_parameter_help section_dividers = [ any(line) and all(c == "-" for c in line) @@ -397,7 +397,7 @@ def test_command_documentation_config_help(monkeypatch): assert "my_command_name" in config_help assert ( - gaps.cli.documentation._cli_formatted(doc.parameter_help) + gaps.cli.documentation._cli_formatted(doc.hpc_parameter_help) in config_help ) assert ".. tabs::" in config_help @@ -458,7 +458,7 @@ def _func2(another_param, d=42, e=None): } assert doc.template_config == expected_config - docstring = doc.parameter_help + docstring = doc.hpc_parameter_help assert "Max num workers" in docstring assert "Path to project points." in docstring assert "More input" in docstring @@ -481,7 +481,7 @@ def _func(another_param, d=42, e=None): ) assert len(doc.signatures) == 1 - docstring = doc.parameter_help + docstring = doc.hpc_parameter_help assert "Max num workers" not in docstring assert "another_param :" not in docstring assert "d :" not in docstring @@ -556,7 +556,7 @@ def preprocessor(another_input, _a_private_input, another_input2=None): ) assert len(doc.signatures) == 3 - docstring = doc.parameter_help + docstring = doc.hpc_parameter_help assert ":max_workers:" in docstring assert "\narg1 :" in docstring assert "\narg2 :" in docstring From 105f81add75f7a0762ac7ddf6afe2ccbb5e8bbaf Mon Sep 17 00:00:00 2001 From: ppinchuk Date: Wed, 31 Jul 2024 11:48:27 -0600 Subject: [PATCH 4/8] Fix test --- tests/cli/test_cli_documentation.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/tests/cli/test_cli_documentation.py b/tests/cli/test_cli_documentation.py index 9bfdf4b4..55e4b1dd 100644 --- a/tests/cli/test_cli_documentation.py +++ b/tests/cli/test_cli_documentation.py @@ -250,16 +250,16 @@ def test_command_documentation_default_exec_values_and_doc(): """Test `CommandDocumentation.default_exec_values` and docs.""" doc = CommandDocumentation(func_no_args) - assert "nodes" not in doc.default_exec_values - assert "max_workers" not in doc.default_exec_values - assert "nodes" not in doc.exec_control_doc - assert "max_workers" not in doc.exec_control_doc + assert ":nodes:" not in doc.default_exec_values + assert ":max_workers:" not in doc.default_exec_values + assert ":nodes:" not in doc.exec_control_doc + assert ":max_workers:" not in doc.exec_control_doc doc = CommandDocumentation(func_no_args, is_split_spatially=True) assert doc.default_exec_values == DEFAULT_EXEC_VALUES - assert "max_workers" not in doc.default_exec_values - assert "nodes" in doc.exec_control_doc - assert "max_workers" not in doc.exec_control_doc + assert ":max_workers:" not in doc.default_exec_values + assert ":nodes:" in doc.exec_control_doc + assert ":max_workers:" not in doc.exec_control_doc def test_command_documentation_required_args(): From dfd5b48e9e0e915aeda254aed82416afd6fbaae2 Mon Sep 17 00:00:00 2001 From: ppinchuk Date: Wed, 31 Jul 2024 12:02:20 -0600 Subject: [PATCH 5/8] Implement `parameter_help` property --- gaps/cli/documentation.py | 28 ++++++++++++++++++++-------- tests/cli/test_cli_documentation.py | 28 ++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+), 8 deletions(-) diff --git a/gaps/cli/documentation.py b/gaps/cli/documentation.py index c950cf63..034e1448 100644 --- a/gaps/cli/documentation.py +++ b/gaps/cli/documentation.py @@ -501,6 +501,23 @@ def template_config(self): ) return config + @property + def _parameter_npd(self): + """NumpyDocString: Parameter help `NumpyDocString` instance.""" + param_doc = NumpyDocString("") + param_doc["Parameters"] = [ + p + for doc in self.docs + for p in doc["Parameters"] + if p.name in self.template_config + ] + return param_doc + + @property + def parameter_help(self): + """str: Parameter help for the func.""" + return str(self._parameter_npd) + @property def hpc_parameter_help(self): """str: Parameter help for the func, including execution control.""" @@ -509,14 +526,9 @@ def hpc_parameter_help(self): for p in NumpyDocString(self.exec_control_doc)["Parameters"] if p.name in {"execution_control", "log_directory", "log_level"} ] - param_only_doc = NumpyDocString("") - param_only_doc["Parameters"] = exec_dict_param + [ - p - for doc in self.docs - for p in doc["Parameters"] - if p.name in self.template_config - ] - return "\n".join(_format_lines(str(param_only_doc).split("\n"))) + param_doc = deepcopy(self._parameter_npd) + param_doc["Parameters"] = exec_dict_param + param_doc["Parameters"] + return "\n".join(_format_lines(str(param_doc).split("\n"))) @property def extended_summary(self): diff --git a/tests/cli/test_cli_documentation.py b/tests/cli/test_cli_documentation.py index 55e4b1dd..c3306810 100644 --- a/tests/cli/test_cli_documentation.py +++ b/tests/cli/test_cli_documentation.py @@ -332,6 +332,34 @@ def func(project_points, a, max_workers, b=1, c=None): assert doc.template_config == expected_config +def test_command_documentation_parameter_help(): + """Test `CommandDocumentation.parameter_help`.""" + + def func(project_points): + """Test func. + + Parameters + ---------- + project_points : str + Path to project points file. + """ + + doc = CommandDocumentation(func, is_split_spatially=True) + param_help = doc.parameter_help + + section_dividers = [ + any(line) and all(c == "-" for c in line) + for line in param_help.split("\n") + ] + assert sum(section_dividers) == 1 + assert "Parameters" in param_help + assert "project_points" in param_help + assert "Path to project points file." in param_help + assert "execution_control :" not in param_help + assert "log_directory :" not in param_help + assert "log_level :" not in param_help + + def test_command_documentation_hpc_parameter_help(): """Test `CommandDocumentation.hpc_parameter_help`.""" From c12acb2de336c8781edfbfc001a699bf64c7f70d Mon Sep 17 00:00:00 2001 From: ppinchuk Date: Wed, 31 Jul 2024 12:02:47 -0600 Subject: [PATCH 6/8] Bump version --- gaps/version.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gaps/version.py b/gaps/version.py index db5f5085..71b479d5 100644 --- a/gaps/version.py +++ b/gaps/version.py @@ -1,3 +1,3 @@ """GAPs Version Number. """ -__version__ = "0.6.11" +__version__ = "0.6.12" From 6a5b3177974e43631e9c3b5253b16230a588c9b0 Mon Sep 17 00:00:00 2001 From: ppinchuk Date: Wed, 31 Jul 2024 12:11:09 -0600 Subject: [PATCH 7/8] Bump numpy req --- requirements.txt | 2 +- tests/test_collection.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/requirements.txt b/requirements.txt index 1b06d97a..1bfe9f69 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,7 +1,7 @@ click>=8.1.3 colorama>=0.4.6 NREL-rex>=0.2.80 -numpy>=1.22.0 +numpy>=2.0.0 numpydoc>=1.5.0 pandas>=2.0.0 psutil>=5.9.2 diff --git a/tests/test_collection.py b/tests/test_collection.py index a7864515..de83567e 100644 --- a/tests/test_collection.py +++ b/tests/test_collection.py @@ -103,7 +103,7 @@ def make_fake_h5_chunks(temp_dir, features, shuffle=False): """ data = np.random.uniform(0, 20, (50, 50, 48)) lon, lat = np.meshgrid(np.linspace(-180, 0, 50), np.linspace(90, 0, 50)) - gids = np.arange(np.product(lat.shape)) + gids = np.arange(np.prod(lat.shape)) if shuffle: np.random.shuffle(gids) From bcab6686e4756bd7d88a8d0dfe729a6a3cffc35c Mon Sep 17 00:00:00 2001 From: ppinchuk Date: Wed, 31 Jul 2024 12:17:04 -0600 Subject: [PATCH 8/8] Don't commit to numpy 2.0 quite yet --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 1bfe9f69..eb072bc7 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,7 +1,7 @@ click>=8.1.3 colorama>=0.4.6 NREL-rex>=0.2.80 -numpy>=2.0.0 +numpy>=1.20,<2.0 numpydoc>=1.5.0 pandas>=2.0.0 psutil>=5.9.2