From e81e941303451ae8d9eccff3cb41c033373e7377 Mon Sep 17 00:00:00 2001 From: Cameron Stark Date: Mon, 27 Jan 2020 10:58:24 -0700 Subject: [PATCH 01/69] use NREL_API_KEY environment variable when available --- pvlib/tests/iotools/test_psm3.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/pvlib/tests/iotools/test_psm3.py b/pvlib/tests/iotools/test_psm3.py index 7ea58acaa0..2eec7f9572 100644 --- a/pvlib/tests/iotools/test_psm3.py +++ b/pvlib/tests/iotools/test_psm3.py @@ -2,6 +2,7 @@ test iotools for PSM3 """ +import os from pvlib.iotools import psm3 from conftest import needs_pandas_0_22, DATA_DIR import numpy as np @@ -21,7 +22,12 @@ 'Temperature Units', 'Pressure Units', 'Wind Direction Units', 'Wind Speed', 'Surface Albedo Units', 'Version'] PVLIB_EMAIL = 'pvlib-admin@googlegroups.com' -DEMO_KEY = 'DEMO_KEY' +try: + DEMO_KEY = os.environ["NREL_API_KEY"] +except KeyError: + print("WARNING: NREL API KEY environment variable not set!") + print("Using DEMO_KEY instead. This may cause unexpected failures.") + DEMO_KEY = 'DEMO_KEY' def assert_psm3_equal(header, data, expected): From 63c489d5cf897d823254d67bd1089fa8b5f2edb7 Mon Sep 17 00:00:00 2001 From: Cameron Stark Date: Mon, 27 Jan 2020 11:09:42 -0700 Subject: [PATCH 02/69] remove try-except clause to ensure that azure env variable is used --- pvlib/tests/iotools/test_psm3.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/pvlib/tests/iotools/test_psm3.py b/pvlib/tests/iotools/test_psm3.py index 2eec7f9572..fa144282e0 100644 --- a/pvlib/tests/iotools/test_psm3.py +++ b/pvlib/tests/iotools/test_psm3.py @@ -22,12 +22,12 @@ 'Temperature Units', 'Pressure Units', 'Wind Direction Units', 'Wind Speed', 'Surface Albedo Units', 'Version'] PVLIB_EMAIL = 'pvlib-admin@googlegroups.com' -try: - DEMO_KEY = os.environ["NREL_API_KEY"] -except KeyError: - print("WARNING: NREL API KEY environment variable not set!") - print("Using DEMO_KEY instead. This may cause unexpected failures.") - DEMO_KEY = 'DEMO_KEY' +# try: +DEMO_KEY = os.environ["NREL_API_KEY"] +# except KeyError: +# print("WARNING: NREL API KEY environment variable not set!") +# print("Using DEMO_KEY instead. This may cause unexpected failures.") +# DEMO_KEY = 'DEMO_KEY' def assert_psm3_equal(header, data, expected): From 3ef167e9a67a540b157c5bc47f19de721e6202d4 Mon Sep 17 00:00:00 2001 From: Cameron Stark Date: Mon, 27 Jan 2020 11:51:37 -0700 Subject: [PATCH 03/69] set environment variable from Azure's secret variables --- azure-pipelines.yml | 288 ++++++++++++++++++++++---------------------- 1 file changed, 145 insertions(+), 143 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 2ad18ae1b8..417bd606bc 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -41,146 +41,148 @@ jobs: codeCoverageTool: Cobertura summaryFileLocation: '$(System.DefaultWorkingDirectory)/**/coverage.xml' reportDirectory: '$(System.DefaultWorkingDirectory)/**/htmlcov' - - -- job: 'Test_conda_linux' - - pool: - vmImage: 'ubuntu-16.04' - - strategy: - matrix: - Python35: - python.version: '35' - Python36: - python.version: '36' - coverage: true - Python37: - python.version: '37' - - steps: - - bash: echo "##vso[task.prependpath]/usr/share/miniconda/bin" - displayName: Add conda to PATH - - script: conda env create --quiet --file ci/requirements-py$(python.version).yml - displayName: Create Anaconda environment - - script: | - source activate test_env - pip install pytest-azurepipelines - pip install -e . - displayName: 'pip dependencies' - - script: | - source activate test_env - conda list - displayName: 'List installed dependencies' - - script: | - source activate test_env - pytest pvlib --junitxml=junit/test-results.xml --cov --cov-report=xml --cov-report=html - displayName: 'pytest' - # - script: | - # source activate test_env - # flake8 pvlib - # displayName: 'flake8' - - task: PublishTestResults@2 - inputs: - testResultsFiles: '**/test-results.xml' - testRunTitle: 'Linux $(python.version)' - - task: PublishCodeCoverageResults@1 - inputs: - codeCoverageTool: Cobertura - summaryFileLocation: '$(System.DefaultWorkingDirectory)/**/coverage.xml' - reportDirectory: '$(System.DefaultWorkingDirectory)/**/htmlcov' - condition: eq(variables['coverage'], true) - - script: | - bash <(curl https://codecov.io/bash) -t bbc2bdbe-5e67-4fef-9cb7-f52fe0b703a8 -f coverage.xml -F adder -F subtractor -F conda - displayName: 'codecov' - condition: eq(variables['coverage'], true) - - -- job: 'Test_conda_windows' - - pool: - vmImage: 'vs2017-win2016' - - strategy: - matrix: - Python35-windows: - python.version: '35' - Python36-windows: - python.version: '36' - Python37-windows: - python.version: '37' - - steps: - - powershell: Write-Host "##vso[task.prependpath]$env:CONDA\Scripts" - displayName: Add conda to PATH - - script: conda env create --quiet --file ci/requirements-py$(python.version).yml - displayName: Create Anaconda environment - - script: | - call activate test_env - pip install pytest-azurepipelines - pip install -e . - displayName: 'pip dependencies' - - script: | - call activate test_env - conda list - displayName: 'List installed dependencies' - - script: | - call activate test_env - pytest pvlib --junitxml=junit/test-results.xml - displayName: 'pytest' - - task: PublishTestResults@2 - inputs: - testResultsFiles: '**/test-results.xml' - testRunTitle: 'Windows $(python.version)' - - -- job: 'Test_bare_macOS_Mojave' - - pool: - vmImage: 'macOS-10.14' - strategy: - matrix: - Python35: - python.version: '3.5' - Python36: - python.version: '3.6' - Python37: - python.version: '3.7' - - steps: - - task: UsePythonVersion@0 - inputs: - versionSpec: '$(python.version)' - - - script: | - pip install pytest pytest-cov pytest-mock pytest-timeout pytest-azurepipelines - pip install -e . - pytest pvlib --junitxml=junit/test-results.xml --cov=pvlib --cov-report=xml --cov-report=html - displayName: 'Test with pytest' - - - task: PublishTestResults@2 - condition: succeededOrFailed() - inputs: - testResultsFiles: '**/test-*.xml' - testRunTitle: 'Publish test results for Python $(python.version)' - - - task: PublishCodeCoverageResults@1 - inputs: - codeCoverageTool: Cobertura - summaryFileLocation: '$(System.DefaultWorkingDirectory)/**/coverage.xml' - reportDirectory: '$(System.DefaultWorkingDirectory)/**/htmlcov' - - -- job: 'Publish' - dependsOn: 'Test_conda_linux' - pool: - vmImage: 'ubuntu-latest' - - steps: - - task: UsePythonVersion@0 - inputs: - versionSpec: '3.x' - architecture: 'x64' - - - script: python setup.py sdist - displayName: 'Build sdist' + env: + NREL_API_KEY: $(NREL_API_KEY) # secret variable mapping from Pipeline to test env + + +# - job: 'Test_conda_linux' + +# pool: +# vmImage: 'ubuntu-16.04' + +# strategy: +# matrix: +# Python35: +# python.version: '35' +# Python36: +# python.version: '36' +# coverage: true +# Python37: +# python.version: '37' + +# steps: +# - bash: echo "##vso[task.prependpath]/usr/share/miniconda/bin" +# displayName: Add conda to PATH +# - script: conda env create --quiet --file ci/requirements-py$(python.version).yml +# displayName: Create Anaconda environment +# - script: | +# source activate test_env +# pip install pytest-azurepipelines +# pip install -e . +# displayName: 'pip dependencies' +# - script: | +# source activate test_env +# conda list +# displayName: 'List installed dependencies' +# - script: | +# source activate test_env +# pytest pvlib --junitxml=junit/test-results.xml --cov --cov-report=xml --cov-report=html +# displayName: 'pytest' +# # - script: | +# # source activate test_env +# # flake8 pvlib +# # displayName: 'flake8' +# - task: PublishTestResults@2 +# inputs: +# testResultsFiles: '**/test-results.xml' +# testRunTitle: 'Linux $(python.version)' +# - task: PublishCodeCoverageResults@1 +# inputs: +# codeCoverageTool: Cobertura +# summaryFileLocation: '$(System.DefaultWorkingDirectory)/**/coverage.xml' +# reportDirectory: '$(System.DefaultWorkingDirectory)/**/htmlcov' +# condition: eq(variables['coverage'], true) +# - script: | +# bash <(curl https://codecov.io/bash) -t bbc2bdbe-5e67-4fef-9cb7-f52fe0b703a8 -f coverage.xml -F adder -F subtractor -F conda +# displayName: 'codecov' +# condition: eq(variables['coverage'], true) + + +# - job: 'Test_conda_windows' + +# pool: +# vmImage: 'vs2017-win2016' + +# strategy: +# matrix: +# Python35-windows: +# python.version: '35' +# Python36-windows: +# python.version: '36' +# Python37-windows: +# python.version: '37' + +# steps: +# - powershell: Write-Host "##vso[task.prependpath]$env:CONDA\Scripts" +# displayName: Add conda to PATH +# - script: conda env create --quiet --file ci/requirements-py$(python.version).yml +# displayName: Create Anaconda environment +# - script: | +# call activate test_env +# pip install pytest-azurepipelines +# pip install -e . +# displayName: 'pip dependencies' +# - script: | +# call activate test_env +# conda list +# displayName: 'List installed dependencies' +# - script: | +# call activate test_env +# pytest pvlib --junitxml=junit/test-results.xml +# displayName: 'pytest' +# - task: PublishTestResults@2 +# inputs: +# testResultsFiles: '**/test-results.xml' +# testRunTitle: 'Windows $(python.version)' + + +# - job: 'Test_bare_macOS_Mojave' + +# pool: +# vmImage: 'macOS-10.14' +# strategy: +# matrix: +# Python35: +# python.version: '3.5' +# Python36: +# python.version: '3.6' +# Python37: +# python.version: '3.7' + +# steps: +# - task: UsePythonVersion@0 +# inputs: +# versionSpec: '$(python.version)' + +# - script: | +# pip install pytest pytest-cov pytest-mock pytest-timeout pytest-azurepipelines +# pip install -e . +# pytest pvlib --junitxml=junit/test-results.xml --cov=pvlib --cov-report=xml --cov-report=html +# displayName: 'Test with pytest' + +# - task: PublishTestResults@2 +# condition: succeededOrFailed() +# inputs: +# testResultsFiles: '**/test-*.xml' +# testRunTitle: 'Publish test results for Python $(python.version)' + +# - task: PublishCodeCoverageResults@1 +# inputs: +# codeCoverageTool: Cobertura +# summaryFileLocation: '$(System.DefaultWorkingDirectory)/**/coverage.xml' +# reportDirectory: '$(System.DefaultWorkingDirectory)/**/htmlcov' + + +# - job: 'Publish' +# dependsOn: 'Test_conda_linux' +# pool: +# vmImage: 'ubuntu-latest' + +# steps: +# - task: UsePythonVersion@0 +# inputs: +# versionSpec: '3.x' +# architecture: 'x64' + +# - script: python setup.py sdist +# displayName: 'Build sdist' From ecb8f790539348d35dec01d706c80d6fb1d78ae0 Mon Sep 17 00:00:00 2001 From: Cameron Stark Date: Mon, 27 Jan 2020 12:07:51 -0700 Subject: [PATCH 04/69] Update azure-pipelines.yml for Azure Pipelines --- azure-pipelines.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 417bd606bc..461bf0a306 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -2,7 +2,8 @@ trigger: - master - +variables: + NREL_API_KEY: $(NREL_API_KEY) # secret variable mapping from Pipeline to test env jobs: @@ -41,8 +42,6 @@ jobs: codeCoverageTool: Cobertura summaryFileLocation: '$(System.DefaultWorkingDirectory)/**/coverage.xml' reportDirectory: '$(System.DefaultWorkingDirectory)/**/htmlcov' - env: - NREL_API_KEY: $(NREL_API_KEY) # secret variable mapping from Pipeline to test env # - job: 'Test_conda_linux' From 0f1333545b9061d0cb824972312b56ae272d63c0 Mon Sep 17 00:00:00 2001 From: Cameron Stark Date: Mon, 27 Jan 2020 12:36:52 -0700 Subject: [PATCH 05/69] Update azure-pipelines.yml for Azure Pipelines within pytest call --- azure-pipelines.yml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 461bf0a306..092cc04375 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -2,8 +2,7 @@ trigger: - master -variables: - NREL_API_KEY: $(NREL_API_KEY) # secret variable mapping from Pipeline to test env + jobs: @@ -26,11 +25,15 @@ jobs: versionSpec: '$(python.version)' - script: | + export NREL_API_KEY=$(NREL_API_KEY) pip install pytest pytest-cov pytest-mock pytest-timeout pytest-azurepipelines pip install -e . pytest pvlib --junitxml=junit/test-results.xml --cov=com --cov-report=xml --cov-report=html displayName: 'Test with pytest' + env: + NREL_API_KEY: $(NREL_API_KEY) + - task: PublishTestResults@2 condition: succeededOrFailed() inputs: @@ -43,7 +46,7 @@ jobs: summaryFileLocation: '$(System.DefaultWorkingDirectory)/**/coverage.xml' reportDirectory: '$(System.DefaultWorkingDirectory)/**/htmlcov' - + # - job: 'Test_conda_linux' # pool: From 31896ca9962b93ac2e70da753abfadb395adbeba Mon Sep 17 00:00:00 2001 From: Cameron Stark Date: Mon, 27 Jan 2020 12:57:57 -0700 Subject: [PATCH 06/69] Update azure-pipelines.yml for Azure Pipelines echo only --- azure-pipelines.yml | 27 ++++----------------------- 1 file changed, 4 insertions(+), 23 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 092cc04375..1de6e02892 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -12,10 +12,6 @@ jobs: vmImage: 'ubuntu-16.04' strategy: matrix: - Python35: - python.version: '3.5' - Python36: - python.version: '3.6' Python37: python.version: '3.7' @@ -25,26 +21,11 @@ jobs: versionSpec: '$(python.version)' - script: | - export NREL_API_KEY=$(NREL_API_KEY) - pip install pytest pytest-cov pytest-mock pytest-timeout pytest-azurepipelines - pip install -e . - pytest pvlib --junitxml=junit/test-results.xml --cov=com --cov-report=xml --cov-report=html - displayName: 'Test with pytest' + echo "below is a test of the nrel api key" + echo $(NREL_API_KEY) + + displayName: 'print env variable' - env: - NREL_API_KEY: $(NREL_API_KEY) - - - task: PublishTestResults@2 - condition: succeededOrFailed() - inputs: - testResultsFiles: '**/test-*.xml' - testRunTitle: 'Publish test results for Python $(python.version)' - - - task: PublishCodeCoverageResults@1 - inputs: - codeCoverageTool: Cobertura - summaryFileLocation: '$(System.DefaultWorkingDirectory)/**/coverage.xml' - reportDirectory: '$(System.DefaultWorkingDirectory)/**/htmlcov' # - job: 'Test_conda_linux' From 5c697735786fe632e999be6790e9f50dd24d3058 Mon Sep 17 00:00:00 2001 From: Cameron Stark Date: Mon, 27 Jan 2020 13:06:23 -0700 Subject: [PATCH 07/69] Update azure-pipelines.yml for Azure Pipelines with python --- azure-pipelines.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 1de6e02892..b43936ec27 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -23,7 +23,7 @@ jobs: - script: | echo "below is a test of the nrel api key" echo $(NREL_API_KEY) - + python -c "import os; print(os.environ['NREL_API_KEY'])" displayName: 'print env variable' From c348fad2486899bf9a9c58b687909f563a6b05c8 Mon Sep 17 00:00:00 2001 From: Cameron Stark Date: Mon, 27 Jan 2020 13:08:50 -0700 Subject: [PATCH 08/69] Update azure-pipelines.yml for Azure Pipelines all os.environ --- azure-pipelines.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index b43936ec27..6e9b4be397 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -23,11 +23,11 @@ jobs: - script: | echo "below is a test of the nrel api key" echo $(NREL_API_KEY) - python -c "import os; print(os.environ['NREL_API_KEY'])" + python -c "import os; print(os.environ)" displayName: 'print env variable' - + # - job: 'Test_conda_linux' # pool: From 6a486313271764b7443c20703d13d5002ea6e195 Mon Sep 17 00:00:00 2001 From: Cameron Stark Date: Mon, 27 Jan 2020 13:13:02 -0700 Subject: [PATCH 09/69] Update azure-pipelines.yml for Azure Pipelines export variable --- azure-pipelines.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 6e9b4be397..6f0a152811 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -23,7 +23,8 @@ jobs: - script: | echo "below is a test of the nrel api key" echo $(NREL_API_KEY) - python -c "import os; print(os.environ)" + export nrelapikey=$(NREL_API_KEY) + python -c "import os; print(os.environ['nrelapikey'])" displayName: 'print env variable' From c56f8ea2ca852171107bd51e09220818f75d59ab Mon Sep 17 00:00:00 2001 From: Cameron Stark Date: Mon, 27 Jan 2020 13:22:13 -0700 Subject: [PATCH 10/69] export Azure secret variable into environment to access from python --- azure-pipelines.yml | 6 ++++-- pvlib/tests/iotools/test_psm3.py | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 6f0a152811..baf63cafd6 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -21,10 +21,12 @@ jobs: versionSpec: '$(python.version)' - script: | - echo "below is a test of the nrel api key" - echo $(NREL_API_KEY) export nrelapikey=$(NREL_API_KEY) python -c "import os; print(os.environ['nrelapikey'])" + pip install pytest pytest-cov pytest-mock pytest-timeout pytest-azurepipelines + pip install -e . + pytest pvlib --junitxml=junit/test-results.xml --cov=com --cov-report=xml --cov-report=html + displayName: 'Test with pytest' displayName: 'print env variable' diff --git a/pvlib/tests/iotools/test_psm3.py b/pvlib/tests/iotools/test_psm3.py index fa144282e0..1e37133d9f 100644 --- a/pvlib/tests/iotools/test_psm3.py +++ b/pvlib/tests/iotools/test_psm3.py @@ -23,7 +23,7 @@ 'Wind Speed', 'Surface Albedo Units', 'Version'] PVLIB_EMAIL = 'pvlib-admin@googlegroups.com' # try: -DEMO_KEY = os.environ["NREL_API_KEY"] +DEMO_KEY = os.environ["nrelapikey"] # except KeyError: # print("WARNING: NREL API KEY environment variable not set!") # print("Using DEMO_KEY instead. This may cause unexpected failures.") From 60323df4dc99dcc1edb70ad6db2166a4c57f9794 Mon Sep 17 00:00:00 2001 From: Cameron Stark Date: Mon, 27 Jan 2020 13:24:55 -0700 Subject: [PATCH 11/69] Update azure-pipelines.yml for Azure Pipelines fix displayName --- azure-pipelines.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index baf63cafd6..820bcc160c 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -27,7 +27,6 @@ jobs: pip install -e . pytest pvlib --junitxml=junit/test-results.xml --cov=com --cov-report=xml --cov-report=html displayName: 'Test with pytest' - displayName: 'print env variable' From 83e35d3eb76a06e3647ab7cb6985a0b7ec3ccf20 Mon Sep 17 00:00:00 2001 From: Cameron Stark Date: Mon, 27 Jan 2020 13:29:39 -0700 Subject: [PATCH 12/69] Update azure-pipelines.yml for Azure Pipelines psm3 test only --- azure-pipelines.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 820bcc160c..a9f22cd80d 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -25,7 +25,7 @@ jobs: python -c "import os; print(os.environ['nrelapikey'])" pip install pytest pytest-cov pytest-mock pytest-timeout pytest-azurepipelines pip install -e . - pytest pvlib --junitxml=junit/test-results.xml --cov=com --cov-report=xml --cov-report=html + pytest pvlib pvlib/tests/iotools/test_psm3.py --junitxml=junit/test-results.xml --cov=com --cov-report=xml --cov-report=html displayName: 'Test with pytest' From ae825beb7dd593d5c652ffa48f6dbc4e7c65f859 Mon Sep 17 00:00:00 2001 From: Cameron Stark Date: Mon, 27 Jan 2020 13:34:14 -0700 Subject: [PATCH 13/69] Update azure-pipelines.yml for Azure Pipelines for real this time --- azure-pipelines.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index a9f22cd80d..e8b76c1fa8 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -23,9 +23,9 @@ jobs: - script: | export nrelapikey=$(NREL_API_KEY) python -c "import os; print(os.environ['nrelapikey'])" - pip install pytest pytest-cov pytest-mock pytest-timeout pytest-azurepipelines + pip install pytest-cov pytest-mock pytest-timeout pytest-azurepipelines pip install -e . - pytest pvlib pvlib/tests/iotools/test_psm3.py --junitxml=junit/test-results.xml --cov=com --cov-report=xml --cov-report=html + displayName: 'Test with pytest' From 5ce5f8f90dfd6fcd2c6a8892f0425304283966de Mon Sep 17 00:00:00 2001 From: Cameron Stark Date: Mon, 27 Jan 2020 13:36:25 -0700 Subject: [PATCH 14/69] Update azure-pipelines.yml for Azure Pipelines for really real this time --- azure-pipelines.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index e8b76c1fa8..a95391a0ed 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -23,9 +23,9 @@ jobs: - script: | export nrelapikey=$(NREL_API_KEY) python -c "import os; print(os.environ['nrelapikey'])" - pip install pytest-cov pytest-mock pytest-timeout pytest-azurepipelines + pip install pytest pytest-cov pytest-mock pytest-timeout pytest-azurepipelines pip install -e . - + pytest pvlib/tests/iotools/test_psm3.py --junitxml=junit/test-results.xml --cov=com --cov-report=xml --cov-report=html displayName: 'Test with pytest' From 6d33c6cfd5456a212035595b4baf6b0b747082fa Mon Sep 17 00:00:00 2001 From: Cameron Stark Date: Mon, 27 Jan 2020 13:44:42 -0700 Subject: [PATCH 15/69] Update azure-pipelines.yml for Azure Pipelines single failing test --- azure-pipelines.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index a95391a0ed..430109fbef 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -25,7 +25,7 @@ jobs: python -c "import os; print(os.environ['nrelapikey'])" pip install pytest pytest-cov pytest-mock pytest-timeout pytest-azurepipelines pip install -e . - pytest pvlib/tests/iotools/test_psm3.py --junitxml=junit/test-results.xml --cov=com --cov-report=xml --cov-report=html + pytest pvlib/tests/iotools/test_psm3.py::test_get_psm3_singleyear --junitxml=junit/test-results.xml --cov=com --cov-report=xml --cov-report=html displayName: 'Test with pytest' From 2596c4f6ec2c17e883c720adbff125a7c9952f1e Mon Sep 17 00:00:00 2001 From: Cameron Stark Date: Mon, 27 Jan 2020 13:46:40 -0700 Subject: [PATCH 16/69] Update azure-pipelines.yml for Azure Pipelines test_get_psm3_tmy --- azure-pipelines.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 430109fbef..68b9345fe4 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -25,7 +25,7 @@ jobs: python -c "import os; print(os.environ['nrelapikey'])" pip install pytest pytest-cov pytest-mock pytest-timeout pytest-azurepipelines pip install -e . - pytest pvlib/tests/iotools/test_psm3.py::test_get_psm3_singleyear --junitxml=junit/test-results.xml --cov=com --cov-report=xml --cov-report=html + pytest pvlib/tests/iotools/test_psm3.py::test_get_psm3_tmy --junitxml=junit/test-results.xml --cov=com --cov-report=xml --cov-report=html displayName: 'Test with pytest' From b16d036d445aaf097f268be57af23bd28ee3963c Mon Sep 17 00:00:00 2001 From: Cameron Stark Date: Mon, 27 Jan 2020 13:48:28 -0700 Subject: [PATCH 17/69] Update azure-pipelines.yml for Azure Pipelines io_input --- azure-pipelines.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 68b9345fe4..87461162bf 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -25,7 +25,7 @@ jobs: python -c "import os; print(os.environ['nrelapikey'])" pip install pytest pytest-cov pytest-mock pytest-timeout pytest-azurepipelines pip install -e . - pytest pvlib/tests/iotools/test_psm3.py::test_get_psm3_tmy --junitxml=junit/test-results.xml --cov=com --cov-report=xml --cov-report=html + pytest pvlib/tests/iotools/test_psm3.py::io_input --junitxml=junit/test-results.xml --cov=com --cov-report=xml --cov-report=html displayName: 'Test with pytest' From edb303c3031f23ad2c8093955e8854359ce8a2a9 Mon Sep 17 00:00:00 2001 From: Cameron Stark Date: Mon, 27 Jan 2020 13:51:28 -0700 Subject: [PATCH 18/69] Update azure-pipelines.yml for Azure Pipelines test_parse_psm3 --- azure-pipelines.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 87461162bf..ef96f0764c 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -25,7 +25,7 @@ jobs: python -c "import os; print(os.environ['nrelapikey'])" pip install pytest pytest-cov pytest-mock pytest-timeout pytest-azurepipelines pip install -e . - pytest pvlib/tests/iotools/test_psm3.py::io_input --junitxml=junit/test-results.xml --cov=com --cov-report=xml --cov-report=html + pytest pvlib/tests/iotools/test_psm3.py::test_parse_psm3 --junitxml=junit/test-results.xml --cov=com --cov-report=xml --cov-report=html displayName: 'Test with pytest' From 8a8013c3b154c17b2aec9261b1449a3396a162dc Mon Sep 17 00:00:00 2001 From: Cameron Stark Date: Mon, 27 Jan 2020 13:53:46 -0700 Subject: [PATCH 19/69] Update azure-pipelines.yml for Azure Pipelines test_read_psm3 --- azure-pipelines.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index ef96f0764c..351052c389 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -25,7 +25,7 @@ jobs: python -c "import os; print(os.environ['nrelapikey'])" pip install pytest pytest-cov pytest-mock pytest-timeout pytest-azurepipelines pip install -e . - pytest pvlib/tests/iotools/test_psm3.py::test_parse_psm3 --junitxml=junit/test-results.xml --cov=com --cov-report=xml --cov-report=html + pytest pvlib/tests/iotools/test_psm3.py::test_read_psm3 --junitxml=junit/test-results.xml --cov=com --cov-report=xml --cov-report=html displayName: 'Test with pytest' From aacb1d6e88a6784a21ce6a89558ead29f7db77b8 Mon Sep 17 00:00:00 2001 From: Cameron Stark Date: Mon, 27 Jan 2020 13:55:30 -0700 Subject: [PATCH 20/69] Update azure-pipelines.yml for Azure Pipelines all test_psm3.py tests --- azure-pipelines.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 351052c389..a95391a0ed 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -25,7 +25,7 @@ jobs: python -c "import os; print(os.environ['nrelapikey'])" pip install pytest pytest-cov pytest-mock pytest-timeout pytest-azurepipelines pip install -e . - pytest pvlib/tests/iotools/test_psm3.py::test_read_psm3 --junitxml=junit/test-results.xml --cov=com --cov-report=xml --cov-report=html + pytest pvlib/tests/iotools/test_psm3.py --junitxml=junit/test-results.xml --cov=com --cov-report=xml --cov-report=html displayName: 'Test with pytest' From 1a7ac117f36d84e39b2e5dad83caa16890196962 Mon Sep 17 00:00:00 2001 From: Cameron Stark Date: Mon, 27 Jan 2020 14:28:59 -0700 Subject: [PATCH 21/69] Update azure-pipelines.yml for Azure Pipelines all python versions --- azure-pipelines.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index a95391a0ed..eb0a678cb5 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -12,6 +12,10 @@ jobs: vmImage: 'ubuntu-16.04' strategy: matrix: + Python35: + python.version: '3.5' + Python36: + python.version: '3.6' Python37: python.version: '3.7' From bc37f2fb7cc41dd9da3764bc4974d1dc44b5dd4c Mon Sep 17 00:00:00 2001 From: Cameron Stark Date: Mon, 27 Jan 2020 10:58:24 -0700 Subject: [PATCH 22/69] use NREL_API_KEY environment variable when available --- pvlib/tests/iotools/test_psm3.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/pvlib/tests/iotools/test_psm3.py b/pvlib/tests/iotools/test_psm3.py index 7ea58acaa0..2eec7f9572 100644 --- a/pvlib/tests/iotools/test_psm3.py +++ b/pvlib/tests/iotools/test_psm3.py @@ -2,6 +2,7 @@ test iotools for PSM3 """ +import os from pvlib.iotools import psm3 from conftest import needs_pandas_0_22, DATA_DIR import numpy as np @@ -21,7 +22,12 @@ 'Temperature Units', 'Pressure Units', 'Wind Direction Units', 'Wind Speed', 'Surface Albedo Units', 'Version'] PVLIB_EMAIL = 'pvlib-admin@googlegroups.com' -DEMO_KEY = 'DEMO_KEY' +try: + DEMO_KEY = os.environ["NREL_API_KEY"] +except KeyError: + print("WARNING: NREL API KEY environment variable not set!") + print("Using DEMO_KEY instead. This may cause unexpected failures.") + DEMO_KEY = 'DEMO_KEY' def assert_psm3_equal(header, data, expected): From 8736f62b10d96f549919abea56cb9152303a96a3 Mon Sep 17 00:00:00 2001 From: Cameron Stark Date: Mon, 27 Jan 2020 11:09:42 -0700 Subject: [PATCH 23/69] remove try-except clause to ensure that azure env variable is used --- pvlib/tests/iotools/test_psm3.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/pvlib/tests/iotools/test_psm3.py b/pvlib/tests/iotools/test_psm3.py index 2eec7f9572..fa144282e0 100644 --- a/pvlib/tests/iotools/test_psm3.py +++ b/pvlib/tests/iotools/test_psm3.py @@ -22,12 +22,12 @@ 'Temperature Units', 'Pressure Units', 'Wind Direction Units', 'Wind Speed', 'Surface Albedo Units', 'Version'] PVLIB_EMAIL = 'pvlib-admin@googlegroups.com' -try: - DEMO_KEY = os.environ["NREL_API_KEY"] -except KeyError: - print("WARNING: NREL API KEY environment variable not set!") - print("Using DEMO_KEY instead. This may cause unexpected failures.") - DEMO_KEY = 'DEMO_KEY' +# try: +DEMO_KEY = os.environ["NREL_API_KEY"] +# except KeyError: +# print("WARNING: NREL API KEY environment variable not set!") +# print("Using DEMO_KEY instead. This may cause unexpected failures.") +# DEMO_KEY = 'DEMO_KEY' def assert_psm3_equal(header, data, expected): From 4f11bb5606b4bfd2d8553456b275034bde4d5fbb Mon Sep 17 00:00:00 2001 From: Cameron Stark Date: Mon, 27 Jan 2020 11:51:37 -0700 Subject: [PATCH 24/69] set environment variable from Azure's secret variables --- azure-pipelines.yml | 288 ++++++++++++++++++++++---------------------- 1 file changed, 145 insertions(+), 143 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 2ad18ae1b8..417bd606bc 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -41,146 +41,148 @@ jobs: codeCoverageTool: Cobertura summaryFileLocation: '$(System.DefaultWorkingDirectory)/**/coverage.xml' reportDirectory: '$(System.DefaultWorkingDirectory)/**/htmlcov' - - -- job: 'Test_conda_linux' - - pool: - vmImage: 'ubuntu-16.04' - - strategy: - matrix: - Python35: - python.version: '35' - Python36: - python.version: '36' - coverage: true - Python37: - python.version: '37' - - steps: - - bash: echo "##vso[task.prependpath]/usr/share/miniconda/bin" - displayName: Add conda to PATH - - script: conda env create --quiet --file ci/requirements-py$(python.version).yml - displayName: Create Anaconda environment - - script: | - source activate test_env - pip install pytest-azurepipelines - pip install -e . - displayName: 'pip dependencies' - - script: | - source activate test_env - conda list - displayName: 'List installed dependencies' - - script: | - source activate test_env - pytest pvlib --junitxml=junit/test-results.xml --cov --cov-report=xml --cov-report=html - displayName: 'pytest' - # - script: | - # source activate test_env - # flake8 pvlib - # displayName: 'flake8' - - task: PublishTestResults@2 - inputs: - testResultsFiles: '**/test-results.xml' - testRunTitle: 'Linux $(python.version)' - - task: PublishCodeCoverageResults@1 - inputs: - codeCoverageTool: Cobertura - summaryFileLocation: '$(System.DefaultWorkingDirectory)/**/coverage.xml' - reportDirectory: '$(System.DefaultWorkingDirectory)/**/htmlcov' - condition: eq(variables['coverage'], true) - - script: | - bash <(curl https://codecov.io/bash) -t bbc2bdbe-5e67-4fef-9cb7-f52fe0b703a8 -f coverage.xml -F adder -F subtractor -F conda - displayName: 'codecov' - condition: eq(variables['coverage'], true) - - -- job: 'Test_conda_windows' - - pool: - vmImage: 'vs2017-win2016' - - strategy: - matrix: - Python35-windows: - python.version: '35' - Python36-windows: - python.version: '36' - Python37-windows: - python.version: '37' - - steps: - - powershell: Write-Host "##vso[task.prependpath]$env:CONDA\Scripts" - displayName: Add conda to PATH - - script: conda env create --quiet --file ci/requirements-py$(python.version).yml - displayName: Create Anaconda environment - - script: | - call activate test_env - pip install pytest-azurepipelines - pip install -e . - displayName: 'pip dependencies' - - script: | - call activate test_env - conda list - displayName: 'List installed dependencies' - - script: | - call activate test_env - pytest pvlib --junitxml=junit/test-results.xml - displayName: 'pytest' - - task: PublishTestResults@2 - inputs: - testResultsFiles: '**/test-results.xml' - testRunTitle: 'Windows $(python.version)' - - -- job: 'Test_bare_macOS_Mojave' - - pool: - vmImage: 'macOS-10.14' - strategy: - matrix: - Python35: - python.version: '3.5' - Python36: - python.version: '3.6' - Python37: - python.version: '3.7' - - steps: - - task: UsePythonVersion@0 - inputs: - versionSpec: '$(python.version)' - - - script: | - pip install pytest pytest-cov pytest-mock pytest-timeout pytest-azurepipelines - pip install -e . - pytest pvlib --junitxml=junit/test-results.xml --cov=pvlib --cov-report=xml --cov-report=html - displayName: 'Test with pytest' - - - task: PublishTestResults@2 - condition: succeededOrFailed() - inputs: - testResultsFiles: '**/test-*.xml' - testRunTitle: 'Publish test results for Python $(python.version)' - - - task: PublishCodeCoverageResults@1 - inputs: - codeCoverageTool: Cobertura - summaryFileLocation: '$(System.DefaultWorkingDirectory)/**/coverage.xml' - reportDirectory: '$(System.DefaultWorkingDirectory)/**/htmlcov' - - -- job: 'Publish' - dependsOn: 'Test_conda_linux' - pool: - vmImage: 'ubuntu-latest' - - steps: - - task: UsePythonVersion@0 - inputs: - versionSpec: '3.x' - architecture: 'x64' - - - script: python setup.py sdist - displayName: 'Build sdist' + env: + NREL_API_KEY: $(NREL_API_KEY) # secret variable mapping from Pipeline to test env + + +# - job: 'Test_conda_linux' + +# pool: +# vmImage: 'ubuntu-16.04' + +# strategy: +# matrix: +# Python35: +# python.version: '35' +# Python36: +# python.version: '36' +# coverage: true +# Python37: +# python.version: '37' + +# steps: +# - bash: echo "##vso[task.prependpath]/usr/share/miniconda/bin" +# displayName: Add conda to PATH +# - script: conda env create --quiet --file ci/requirements-py$(python.version).yml +# displayName: Create Anaconda environment +# - script: | +# source activate test_env +# pip install pytest-azurepipelines +# pip install -e . +# displayName: 'pip dependencies' +# - script: | +# source activate test_env +# conda list +# displayName: 'List installed dependencies' +# - script: | +# source activate test_env +# pytest pvlib --junitxml=junit/test-results.xml --cov --cov-report=xml --cov-report=html +# displayName: 'pytest' +# # - script: | +# # source activate test_env +# # flake8 pvlib +# # displayName: 'flake8' +# - task: PublishTestResults@2 +# inputs: +# testResultsFiles: '**/test-results.xml' +# testRunTitle: 'Linux $(python.version)' +# - task: PublishCodeCoverageResults@1 +# inputs: +# codeCoverageTool: Cobertura +# summaryFileLocation: '$(System.DefaultWorkingDirectory)/**/coverage.xml' +# reportDirectory: '$(System.DefaultWorkingDirectory)/**/htmlcov' +# condition: eq(variables['coverage'], true) +# - script: | +# bash <(curl https://codecov.io/bash) -t bbc2bdbe-5e67-4fef-9cb7-f52fe0b703a8 -f coverage.xml -F adder -F subtractor -F conda +# displayName: 'codecov' +# condition: eq(variables['coverage'], true) + + +# - job: 'Test_conda_windows' + +# pool: +# vmImage: 'vs2017-win2016' + +# strategy: +# matrix: +# Python35-windows: +# python.version: '35' +# Python36-windows: +# python.version: '36' +# Python37-windows: +# python.version: '37' + +# steps: +# - powershell: Write-Host "##vso[task.prependpath]$env:CONDA\Scripts" +# displayName: Add conda to PATH +# - script: conda env create --quiet --file ci/requirements-py$(python.version).yml +# displayName: Create Anaconda environment +# - script: | +# call activate test_env +# pip install pytest-azurepipelines +# pip install -e . +# displayName: 'pip dependencies' +# - script: | +# call activate test_env +# conda list +# displayName: 'List installed dependencies' +# - script: | +# call activate test_env +# pytest pvlib --junitxml=junit/test-results.xml +# displayName: 'pytest' +# - task: PublishTestResults@2 +# inputs: +# testResultsFiles: '**/test-results.xml' +# testRunTitle: 'Windows $(python.version)' + + +# - job: 'Test_bare_macOS_Mojave' + +# pool: +# vmImage: 'macOS-10.14' +# strategy: +# matrix: +# Python35: +# python.version: '3.5' +# Python36: +# python.version: '3.6' +# Python37: +# python.version: '3.7' + +# steps: +# - task: UsePythonVersion@0 +# inputs: +# versionSpec: '$(python.version)' + +# - script: | +# pip install pytest pytest-cov pytest-mock pytest-timeout pytest-azurepipelines +# pip install -e . +# pytest pvlib --junitxml=junit/test-results.xml --cov=pvlib --cov-report=xml --cov-report=html +# displayName: 'Test with pytest' + +# - task: PublishTestResults@2 +# condition: succeededOrFailed() +# inputs: +# testResultsFiles: '**/test-*.xml' +# testRunTitle: 'Publish test results for Python $(python.version)' + +# - task: PublishCodeCoverageResults@1 +# inputs: +# codeCoverageTool: Cobertura +# summaryFileLocation: '$(System.DefaultWorkingDirectory)/**/coverage.xml' +# reportDirectory: '$(System.DefaultWorkingDirectory)/**/htmlcov' + + +# - job: 'Publish' +# dependsOn: 'Test_conda_linux' +# pool: +# vmImage: 'ubuntu-latest' + +# steps: +# - task: UsePythonVersion@0 +# inputs: +# versionSpec: '3.x' +# architecture: 'x64' + +# - script: python setup.py sdist +# displayName: 'Build sdist' From f7620b673505a940d7802bc013e4c1ff84e73ded Mon Sep 17 00:00:00 2001 From: Cameron Stark Date: Mon, 27 Jan 2020 12:07:51 -0700 Subject: [PATCH 25/69] Update azure-pipelines.yml for Azure Pipelines --- azure-pipelines.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 417bd606bc..461bf0a306 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -2,7 +2,8 @@ trigger: - master - +variables: + NREL_API_KEY: $(NREL_API_KEY) # secret variable mapping from Pipeline to test env jobs: @@ -41,8 +42,6 @@ jobs: codeCoverageTool: Cobertura summaryFileLocation: '$(System.DefaultWorkingDirectory)/**/coverage.xml' reportDirectory: '$(System.DefaultWorkingDirectory)/**/htmlcov' - env: - NREL_API_KEY: $(NREL_API_KEY) # secret variable mapping from Pipeline to test env # - job: 'Test_conda_linux' From 937f05056e7f738a1670b8700d3458f5a00ab5d4 Mon Sep 17 00:00:00 2001 From: Cameron Stark Date: Mon, 27 Jan 2020 12:36:52 -0700 Subject: [PATCH 26/69] Update azure-pipelines.yml for Azure Pipelines within pytest call --- azure-pipelines.yml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 461bf0a306..092cc04375 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -2,8 +2,7 @@ trigger: - master -variables: - NREL_API_KEY: $(NREL_API_KEY) # secret variable mapping from Pipeline to test env + jobs: @@ -26,11 +25,15 @@ jobs: versionSpec: '$(python.version)' - script: | + export NREL_API_KEY=$(NREL_API_KEY) pip install pytest pytest-cov pytest-mock pytest-timeout pytest-azurepipelines pip install -e . pytest pvlib --junitxml=junit/test-results.xml --cov=com --cov-report=xml --cov-report=html displayName: 'Test with pytest' + env: + NREL_API_KEY: $(NREL_API_KEY) + - task: PublishTestResults@2 condition: succeededOrFailed() inputs: @@ -43,7 +46,7 @@ jobs: summaryFileLocation: '$(System.DefaultWorkingDirectory)/**/coverage.xml' reportDirectory: '$(System.DefaultWorkingDirectory)/**/htmlcov' - + # - job: 'Test_conda_linux' # pool: From 27b370cefa5318fbde69b063ef8b9b8cd662cdad Mon Sep 17 00:00:00 2001 From: Cameron Stark Date: Mon, 27 Jan 2020 12:57:57 -0700 Subject: [PATCH 27/69] Update azure-pipelines.yml for Azure Pipelines echo only --- azure-pipelines.yml | 27 ++++----------------------- 1 file changed, 4 insertions(+), 23 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 092cc04375..1de6e02892 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -12,10 +12,6 @@ jobs: vmImage: 'ubuntu-16.04' strategy: matrix: - Python35: - python.version: '3.5' - Python36: - python.version: '3.6' Python37: python.version: '3.7' @@ -25,26 +21,11 @@ jobs: versionSpec: '$(python.version)' - script: | - export NREL_API_KEY=$(NREL_API_KEY) - pip install pytest pytest-cov pytest-mock pytest-timeout pytest-azurepipelines - pip install -e . - pytest pvlib --junitxml=junit/test-results.xml --cov=com --cov-report=xml --cov-report=html - displayName: 'Test with pytest' + echo "below is a test of the nrel api key" + echo $(NREL_API_KEY) + + displayName: 'print env variable' - env: - NREL_API_KEY: $(NREL_API_KEY) - - - task: PublishTestResults@2 - condition: succeededOrFailed() - inputs: - testResultsFiles: '**/test-*.xml' - testRunTitle: 'Publish test results for Python $(python.version)' - - - task: PublishCodeCoverageResults@1 - inputs: - codeCoverageTool: Cobertura - summaryFileLocation: '$(System.DefaultWorkingDirectory)/**/coverage.xml' - reportDirectory: '$(System.DefaultWorkingDirectory)/**/htmlcov' # - job: 'Test_conda_linux' From 6068d8323bb58a0c9d3acdceb992bebdc3f0c9e4 Mon Sep 17 00:00:00 2001 From: Cameron Stark Date: Mon, 27 Jan 2020 13:06:23 -0700 Subject: [PATCH 28/69] Update azure-pipelines.yml for Azure Pipelines with python --- azure-pipelines.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 1de6e02892..b43936ec27 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -23,7 +23,7 @@ jobs: - script: | echo "below is a test of the nrel api key" echo $(NREL_API_KEY) - + python -c "import os; print(os.environ['NREL_API_KEY'])" displayName: 'print env variable' From 672ec66d61058c281cf991278a378b651c3912c3 Mon Sep 17 00:00:00 2001 From: Cameron Stark Date: Mon, 27 Jan 2020 13:08:50 -0700 Subject: [PATCH 29/69] Update azure-pipelines.yml for Azure Pipelines all os.environ --- azure-pipelines.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index b43936ec27..6e9b4be397 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -23,11 +23,11 @@ jobs: - script: | echo "below is a test of the nrel api key" echo $(NREL_API_KEY) - python -c "import os; print(os.environ['NREL_API_KEY'])" + python -c "import os; print(os.environ)" displayName: 'print env variable' - + # - job: 'Test_conda_linux' # pool: From 572a861f2b803e7c050b584879cd1d41a2a09217 Mon Sep 17 00:00:00 2001 From: Cameron Stark Date: Mon, 27 Jan 2020 13:13:02 -0700 Subject: [PATCH 30/69] Update azure-pipelines.yml for Azure Pipelines export variable --- azure-pipelines.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 6e9b4be397..6f0a152811 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -23,7 +23,8 @@ jobs: - script: | echo "below is a test of the nrel api key" echo $(NREL_API_KEY) - python -c "import os; print(os.environ)" + export nrelapikey=$(NREL_API_KEY) + python -c "import os; print(os.environ['nrelapikey'])" displayName: 'print env variable' From cea3edabb7d4a4b108ca8aa5dc16ba8765253fee Mon Sep 17 00:00:00 2001 From: Cameron Stark Date: Mon, 27 Jan 2020 13:22:13 -0700 Subject: [PATCH 31/69] export Azure secret variable into environment to access from python --- azure-pipelines.yml | 6 ++++-- pvlib/tests/iotools/test_psm3.py | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 6f0a152811..baf63cafd6 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -21,10 +21,12 @@ jobs: versionSpec: '$(python.version)' - script: | - echo "below is a test of the nrel api key" - echo $(NREL_API_KEY) export nrelapikey=$(NREL_API_KEY) python -c "import os; print(os.environ['nrelapikey'])" + pip install pytest pytest-cov pytest-mock pytest-timeout pytest-azurepipelines + pip install -e . + pytest pvlib --junitxml=junit/test-results.xml --cov=com --cov-report=xml --cov-report=html + displayName: 'Test with pytest' displayName: 'print env variable' diff --git a/pvlib/tests/iotools/test_psm3.py b/pvlib/tests/iotools/test_psm3.py index fa144282e0..1e37133d9f 100644 --- a/pvlib/tests/iotools/test_psm3.py +++ b/pvlib/tests/iotools/test_psm3.py @@ -23,7 +23,7 @@ 'Wind Speed', 'Surface Albedo Units', 'Version'] PVLIB_EMAIL = 'pvlib-admin@googlegroups.com' # try: -DEMO_KEY = os.environ["NREL_API_KEY"] +DEMO_KEY = os.environ["nrelapikey"] # except KeyError: # print("WARNING: NREL API KEY environment variable not set!") # print("Using DEMO_KEY instead. This may cause unexpected failures.") From 2c8370d64034e409155c787509566699879b9e96 Mon Sep 17 00:00:00 2001 From: Cameron Stark Date: Wed, 29 Jan 2020 11:03:46 -0700 Subject: [PATCH 32/69] temporary test_blah function and get_psm3 delayer --- pvlib/tests/iotools/test_psm3.py | 35 ++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/pvlib/tests/iotools/test_psm3.py b/pvlib/tests/iotools/test_psm3.py index 1e37133d9f..003f6cc603 100644 --- a/pvlib/tests/iotools/test_psm3.py +++ b/pvlib/tests/iotools/test_psm3.py @@ -10,6 +10,7 @@ import pytest from requests import HTTPError from io import StringIO +import time TMY_TEST_DATA = DATA_DIR / 'test_psm3_tmy-2017.csv' YEAR_TEST_DATA = DATA_DIR / 'test_psm3_2017.csv' @@ -55,6 +56,40 @@ def assert_psm3_equal(header, data, expected): assert (data.index.tzinfo.zone == 'Etc/GMT%+d' % -header['Time Zone']) +def delay_get_psm3(*args, **kwargs): + """Add a delay after a get_psm3() call""" + i = 0 + while True: + try: + # execute get_psm3 + header, data = psm3.get_psm3(*args, **kwargs) + except HTTPError as e: + # throw HTTPError as long as it's not due to OVER_RATE_LIMIT + if "OVER_RATE_LIMIT" not in str(e): + raise + break + if "OVER_RATE_LIMIT" not in str(e): + raise + break + print("over rate limit hit") + time.sleep(i) + i+=1 + # break from loop if no error found + break + + return header, data + +@needs_pandas_0_22 +def test_blah(): + with pytest.raises(HTTPError) as bad_key_msg: + delay_get_psm3(LATITUDE, LONGITUDE, api_key='BAD', email=PVLIB_EMAIL) + with pytest.raises(HTTPError) as bad_key_msg: + delay_get_psm3(51, -5, DEMO_KEY, PVLIB_EMAIL) + with pytest.raises(HTTPError) as bad_key_msg: + delay_get_psm3(LATITUDE, LONGITUDE, DEMO_KEY, PVLIB_EMAIL, names='bad') + header, data = delay_get_psm3(LATITUDE, LONGITUDE, DEMO_KEY, PVLIB_EMAIL, + names='tmy-2017') + @needs_pandas_0_22 def test_get_psm3_tmy(): """test get_psm3 with a TMY""" From 1ef3af620979963bac6d765a79cfe0afe068f104 Mon Sep 17 00:00:00 2001 From: Cameron Stark Date: Wed, 29 Jan 2020 11:28:52 -0700 Subject: [PATCH 33/69] improve delay_get_psm3(), replace get_psm3() calls --- pvlib/tests/iotools/test_psm3.py | 58 +++++++++++++------------------- 1 file changed, 24 insertions(+), 34 deletions(-) diff --git a/pvlib/tests/iotools/test_psm3.py b/pvlib/tests/iotools/test_psm3.py index 003f6cc603..4a9f38ca4a 100644 --- a/pvlib/tests/iotools/test_psm3.py +++ b/pvlib/tests/iotools/test_psm3.py @@ -57,80 +57,70 @@ def assert_psm3_equal(header, data, expected): def delay_get_psm3(*args, **kwargs): - """Add a delay after a get_psm3() call""" - i = 0 + """Repeat get_psm3() call if OVER_RATE_LIMIT error occurs otherwise + allow HTTPError to raise. Sleep times increase by one second for + every OVER_RATE_LIMIT HTTPError in a row. Return (header, data) from + get_psm3() as normal. + """ + sleep_time = 0 while True: try: # execute get_psm3 header, data = psm3.get_psm3(*args, **kwargs) except HTTPError as e: - # throw HTTPError as long as it's not due to OVER_RATE_LIMIT - if "OVER_RATE_LIMIT" not in str(e): - raise - break - if "OVER_RATE_LIMIT" not in str(e): - raise - break - print("over rate limit hit") - time.sleep(i) - i+=1 - # break from loop if no error found - break - + if "OVER_RATE_LIMIT" in str(e): + # retry command after sleeping for a time + time.sleep(sleep_time) + sleep_time += 1 + continue + # raise HTTPError if not due to OVER_RATE_LIMIT + raise + else: + break return header, data -@needs_pandas_0_22 -def test_blah(): - with pytest.raises(HTTPError) as bad_key_msg: - delay_get_psm3(LATITUDE, LONGITUDE, api_key='BAD', email=PVLIB_EMAIL) - with pytest.raises(HTTPError) as bad_key_msg: - delay_get_psm3(51, -5, DEMO_KEY, PVLIB_EMAIL) - with pytest.raises(HTTPError) as bad_key_msg: - delay_get_psm3(LATITUDE, LONGITUDE, DEMO_KEY, PVLIB_EMAIL, names='bad') - header, data = delay_get_psm3(LATITUDE, LONGITUDE, DEMO_KEY, PVLIB_EMAIL, - names='tmy-2017') @needs_pandas_0_22 def test_get_psm3_tmy(): """test get_psm3 with a TMY""" - header, data = psm3.get_psm3(LATITUDE, LONGITUDE, DEMO_KEY, PVLIB_EMAIL, + header, data = delay_get_psm3(LATITUDE, LONGITUDE, DEMO_KEY, PVLIB_EMAIL, names='tmy-2017') expected = pd.read_csv(TMY_TEST_DATA) assert_psm3_equal(header, data, expected) # check errors with pytest.raises(HTTPError): # HTTP 403 forbidden because api_key is rejected - psm3.get_psm3(LATITUDE, LONGITUDE, api_key='BAD', email=PVLIB_EMAIL) + delay_get_psm3(LATITUDE, LONGITUDE, api_key='BAD', email=PVLIB_EMAIL) with pytest.raises(HTTPError): # coordinates were not found in the NSRDB - psm3.get_psm3(51, -5, DEMO_KEY, PVLIB_EMAIL) + delay_get_psm3(51, -5, DEMO_KEY, PVLIB_EMAIL) with pytest.raises(HTTPError): # names is not one of the available options - psm3.get_psm3(LATITUDE, LONGITUDE, DEMO_KEY, PVLIB_EMAIL, names='bad') + delay_get_psm3(LATITUDE, LONGITUDE, DEMO_KEY, PVLIB_EMAIL, names='bad') @needs_pandas_0_22 def test_get_psm3_singleyear(): """test get_psm3 with a single year""" - header, data = psm3.get_psm3(LATITUDE, LONGITUDE, DEMO_KEY, PVLIB_EMAIL, + header, data = delay_get_psm3(LATITUDE, LONGITUDE, DEMO_KEY, PVLIB_EMAIL, names='2017', interval=30) expected = pd.read_csv(YEAR_TEST_DATA) assert_psm3_equal(header, data, expected) # check leap day - _, data_2012 = psm3.get_psm3(LATITUDE, LONGITUDE, DEMO_KEY, PVLIB_EMAIL, + _, data_2012 = delay_get_psm3(LATITUDE, LONGITUDE, DEMO_KEY, PVLIB_EMAIL, names='2012', interval=60, leap_day=True) assert len(data_2012) == (8760+24) # check errors with pytest.raises(HTTPError): # HTTP 403 forbidden because api_key is rejected - psm3.get_psm3(LATITUDE, LONGITUDE, api_key='BAD', email=PVLIB_EMAIL, + delay_get_psm3(LATITUDE, LONGITUDE, api_key='BAD', email=PVLIB_EMAIL, names='2017') with pytest.raises(HTTPError): # coordinates were not found in the NSRDB - psm3.get_psm3(51, -5, DEMO_KEY, PVLIB_EMAIL, names='2017') + delay_get_psm3(51, -5, DEMO_KEY, PVLIB_EMAIL, names='2017') with pytest.raises(HTTPError): # intervals can only be 30 or 60 minutes - psm3.get_psm3(LATITUDE, LONGITUDE, DEMO_KEY, PVLIB_EMAIL, names='2017', + delay_get_psm3(LATITUDE, LONGITUDE, DEMO_KEY, PVLIB_EMAIL, names='2017', interval=15) From e764bfa7d69d1864c44b0cc799338fd12aeb82c8 Mon Sep 17 00:00:00 2001 From: Cameron Stark Date: Wed, 29 Jan 2020 11:33:42 -0700 Subject: [PATCH 34/69] set DEMO_KEY to environment variable if available --- pvlib/tests/iotools/test_psm3.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/pvlib/tests/iotools/test_psm3.py b/pvlib/tests/iotools/test_psm3.py index 4a9f38ca4a..6fe929fad5 100644 --- a/pvlib/tests/iotools/test_psm3.py +++ b/pvlib/tests/iotools/test_psm3.py @@ -23,12 +23,12 @@ 'Temperature Units', 'Pressure Units', 'Wind Direction Units', 'Wind Speed', 'Surface Albedo Units', 'Version'] PVLIB_EMAIL = 'pvlib-admin@googlegroups.com' -# try: -DEMO_KEY = os.environ["nrelapikey"] -# except KeyError: -# print("WARNING: NREL API KEY environment variable not set!") -# print("Using DEMO_KEY instead. This may cause unexpected failures.") -# DEMO_KEY = 'DEMO_KEY' +try: + DEMO_KEY = os.environ["NREL_API_KEY"] +except KeyError: + print("WARNING: NREL API KEY environment variable not set!") + print("Using DEMO_KEY instead. This may cause unexpected failures.") + DEMO_KEY = 'DEMO_KEY' def assert_psm3_equal(header, data, expected): From 78ea6a6438df8ea69a0c9f9ee041e6077d9f3bde Mon Sep 17 00:00:00 2001 From: Cameron Stark Date: Wed, 29 Jan 2020 11:45:24 -0700 Subject: [PATCH 35/69] update azure-pipelines basic script for testing --- azure-pipelines.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index baf63cafd6..0ceea670cf 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -21,8 +21,7 @@ jobs: versionSpec: '$(python.version)' - script: | - export nrelapikey=$(NREL_API_KEY) - python -c "import os; print(os.environ['nrelapikey'])" + export NREL_API_KEY=$(nrel_api_key) pip install pytest pytest-cov pytest-mock pytest-timeout pytest-azurepipelines pip install -e . pytest pvlib --junitxml=junit/test-results.xml --cov=com --cov-report=xml --cov-report=html From 7a1b5a14bea1437927983e4d4b281636041931ef Mon Sep 17 00:00:00 2001 From: Cameron Stark Date: Wed, 29 Jan 2020 12:00:07 -0700 Subject: [PATCH 36/69] match azure secret variable --- azure-pipelines.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index a1641ca51e..3db34b31f3 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -21,7 +21,7 @@ jobs: versionSpec: '$(python.version)' - script: | - export NREL_API_KEY=$(nrel_api_key) + export NREL_API_KEY=$(nrelApiKey) pip install pytest pytest-cov pytest-mock pytest-timeout pytest-azurepipelines pip install -e . pytest pvlib/tests/iotools/test_psm3.py --junitxml=junit/test-results.xml --cov=com --cov-report=xml --cov-report=html From 538056761234ac0a21778f7f71ff9d53eee26378 Mon Sep 17 00:00:00 2001 From: Cameron Stark Date: Wed, 29 Jan 2020 12:07:15 -0700 Subject: [PATCH 37/69] return to full suite of testing on azure --- azure-pipelines.yml | 298 +++++++++++++++++++++++--------------------- 1 file changed, 157 insertions(+), 141 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 3db34b31f3..7b3c94ff50 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -12,6 +12,10 @@ jobs: vmImage: 'ubuntu-16.04' strategy: matrix: + Python35: + python.version: '3.5' + Python36: + python.version: '3.6' Python37: python.version: '3.7' @@ -27,145 +31,157 @@ jobs: pytest pvlib/tests/iotools/test_psm3.py --junitxml=junit/test-results.xml --cov=com --cov-report=xml --cov-report=html displayName: 'Test with pytest' + - task: PublishTestResults@2 + condition: succeededOrFailed() + inputs: + testResultsFiles: '**/test-*.xml' + testRunTitle: 'Publish test results for Python $(python.version)' + + - task: PublishCodeCoverageResults@1 + inputs: + codeCoverageTool: Cobertura + summaryFileLocation: '$(System.DefaultWorkingDirectory)/**/coverage.xml' + reportDirectory: '$(System.DefaultWorkingDirectory)/**/htmlcov' + + +- job: 'Test_conda_linux' + + pool: + vmImage: 'ubuntu-16.04' + + strategy: + matrix: + Python35: + python.version: '35' + Python36: + python.version: '36' + coverage: true + Python37: + python.version: '37' + + steps: + - bash: echo "##vso[task.prependpath]/usr/share/miniconda/bin" + displayName: Add conda to PATH + - script: conda env create --quiet --file ci/requirements-py$(python.version).yml + displayName: Create Anaconda environment + - script: | + source activate test_env + pip install pytest-azurepipelines + pip install -e . + displayName: 'pip dependencies' + - script: | + source activate test_env + conda list + displayName: 'List installed dependencies' + - script: | + source activate test_env + pytest pvlib --junitxml=junit/test-results.xml --cov --cov-report=xml --cov-report=html + displayName: 'pytest' + # - script: | + # source activate test_env + # flake8 pvlib + # displayName: 'flake8' + - task: PublishTestResults@2 + inputs: + testResultsFiles: '**/test-results.xml' + testRunTitle: 'Linux $(python.version)' + - task: PublishCodeCoverageResults@1 + inputs: + codeCoverageTool: Cobertura + summaryFileLocation: '$(System.DefaultWorkingDirectory)/**/coverage.xml' + reportDirectory: '$(System.DefaultWorkingDirectory)/**/htmlcov' + condition: eq(variables['coverage'], true) + - script: | + bash <(curl https://codecov.io/bash) -t bbc2bdbe-5e67-4fef-9cb7-f52fe0b703a8 -f coverage.xml -F adder -F subtractor -F conda + displayName: 'codecov' + condition: eq(variables['coverage'], true) + + +- job: 'Test_conda_windows' + + pool: + vmImage: 'vs2017-win2016' + + strategy: + matrix: + Python35-windows: + python.version: '35' + Python36-windows: + python.version: '36' + Python37-windows: + python.version: '37' + + steps: + - powershell: Write-Host "##vso[task.prependpath]$env:CONDA\Scripts" + displayName: Add conda to PATH + - script: conda env create --quiet --file ci/requirements-py$(python.version).yml + displayName: Create Anaconda environment + - script: | + call activate test_env + pip install pytest-azurepipelines + pip install -e . + displayName: 'pip dependencies' + - script: | + call activate test_env + conda list + displayName: 'List installed dependencies' + - script: | + call activate test_env + pytest pvlib --junitxml=junit/test-results.xml + displayName: 'pytest' + - task: PublishTestResults@2 + inputs: + testResultsFiles: '**/test-results.xml' + testRunTitle: 'Windows $(python.version)' + + +- job: 'Test_bare_macOS_Mojave' + + pool: + vmImage: 'macOS-10.14' + strategy: + matrix: + Python35: + python.version: '3.5' + Python36: + python.version: '3.6' + Python37: + python.version: '3.7' + + steps: + - task: UsePythonVersion@0 + inputs: + versionSpec: '$(python.version)' + + - script: | + pip install pytest pytest-cov pytest-mock pytest-timeout pytest-azurepipelines + pip install -e . + pytest pvlib --junitxml=junit/test-results.xml --cov=pvlib --cov-report=xml --cov-report=html + displayName: 'Test with pytest' + + - task: PublishTestResults@2 + condition: succeededOrFailed() + inputs: + testResultsFiles: '**/test-*.xml' + testRunTitle: 'Publish test results for Python $(python.version)' + + - task: PublishCodeCoverageResults@1 + inputs: + codeCoverageTool: Cobertura + summaryFileLocation: '$(System.DefaultWorkingDirectory)/**/coverage.xml' + reportDirectory: '$(System.DefaultWorkingDirectory)/**/htmlcov' + + +- job: 'Publish' + dependsOn: 'Test_conda_linux' + pool: + vmImage: 'ubuntu-latest' + + steps: + - task: UsePythonVersion@0 + inputs: + versionSpec: '3.x' + architecture: 'x64' -# - job: 'Test_conda_linux' - -# pool: -# vmImage: 'ubuntu-16.04' - -# strategy: -# matrix: -# Python35: -# python.version: '35' -# Python36: -# python.version: '36' -# coverage: true -# Python37: -# python.version: '37' - -# steps: -# - bash: echo "##vso[task.prependpath]/usr/share/miniconda/bin" -# displayName: Add conda to PATH -# - script: conda env create --quiet --file ci/requirements-py$(python.version).yml -# displayName: Create Anaconda environment -# - script: | -# source activate test_env -# pip install pytest-azurepipelines -# pip install -e . -# displayName: 'pip dependencies' -# - script: | -# source activate test_env -# conda list -# displayName: 'List installed dependencies' -# - script: | -# source activate test_env -# pytest pvlib --junitxml=junit/test-results.xml --cov --cov-report=xml --cov-report=html -# displayName: 'pytest' -# # - script: | -# # source activate test_env -# # flake8 pvlib -# # displayName: 'flake8' -# - task: PublishTestResults@2 -# inputs: -# testResultsFiles: '**/test-results.xml' -# testRunTitle: 'Linux $(python.version)' -# - task: PublishCodeCoverageResults@1 -# inputs: -# codeCoverageTool: Cobertura -# summaryFileLocation: '$(System.DefaultWorkingDirectory)/**/coverage.xml' -# reportDirectory: '$(System.DefaultWorkingDirectory)/**/htmlcov' -# condition: eq(variables['coverage'], true) -# - script: | -# bash <(curl https://codecov.io/bash) -t bbc2bdbe-5e67-4fef-9cb7-f52fe0b703a8 -f coverage.xml -F adder -F subtractor -F conda -# displayName: 'codecov' -# condition: eq(variables['coverage'], true) - - -# - job: 'Test_conda_windows' - -# pool: -# vmImage: 'vs2017-win2016' - -# strategy: -# matrix: -# Python35-windows: -# python.version: '35' -# Python36-windows: -# python.version: '36' -# Python37-windows: -# python.version: '37' - -# steps: -# - powershell: Write-Host "##vso[task.prependpath]$env:CONDA\Scripts" -# displayName: Add conda to PATH -# - script: conda env create --quiet --file ci/requirements-py$(python.version).yml -# displayName: Create Anaconda environment -# - script: | -# call activate test_env -# pip install pytest-azurepipelines -# pip install -e . -# displayName: 'pip dependencies' -# - script: | -# call activate test_env -# conda list -# displayName: 'List installed dependencies' -# - script: | -# call activate test_env -# pytest pvlib --junitxml=junit/test-results.xml -# displayName: 'pytest' -# - task: PublishTestResults@2 -# inputs: -# testResultsFiles: '**/test-results.xml' -# testRunTitle: 'Windows $(python.version)' - - -# - job: 'Test_bare_macOS_Mojave' - -# pool: -# vmImage: 'macOS-10.14' -# strategy: -# matrix: -# Python35: -# python.version: '3.5' -# Python36: -# python.version: '3.6' -# Python37: -# python.version: '3.7' - -# steps: -# - task: UsePythonVersion@0 -# inputs: -# versionSpec: '$(python.version)' - -# - script: | -# pip install pytest pytest-cov pytest-mock pytest-timeout pytest-azurepipelines -# pip install -e . -# pytest pvlib --junitxml=junit/test-results.xml --cov=pvlib --cov-report=xml --cov-report=html -# displayName: 'Test with pytest' - -# - task: PublishTestResults@2 -# condition: succeededOrFailed() -# inputs: -# testResultsFiles: '**/test-*.xml' -# testRunTitle: 'Publish test results for Python $(python.version)' - -# - task: PublishCodeCoverageResults@1 -# inputs: -# codeCoverageTool: Cobertura -# summaryFileLocation: '$(System.DefaultWorkingDirectory)/**/coverage.xml' -# reportDirectory: '$(System.DefaultWorkingDirectory)/**/htmlcov' - - -# - job: 'Publish' -# dependsOn: 'Test_conda_linux' -# pool: -# vmImage: 'ubuntu-latest' - -# steps: -# - task: UsePythonVersion@0 -# inputs: -# versionSpec: '3.x' -# architecture: 'x64' - -# - script: python setup.py sdist -# displayName: 'Build sdist' + - script: python setup.py sdist + displayName: 'Build sdist' From ea8acd5cbce21a98192a0049b493f77b88808644 Mon Sep 17 00:00:00 2001 From: Cameron Stark Date: Wed, 29 Jan 2020 13:07:58 -0700 Subject: [PATCH 38/69] return test_psm3() specific pytest call to general --- azure-pipelines.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 7b3c94ff50..622b1dde70 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -25,10 +25,10 @@ jobs: versionSpec: '$(python.version)' - script: | - export NREL_API_KEY=$(nrelApiKey) pip install pytest pytest-cov pytest-mock pytest-timeout pytest-azurepipelines pip install -e . - pytest pvlib/tests/iotools/test_psm3.py --junitxml=junit/test-results.xml --cov=com --cov-report=xml --cov-report=html + export NREL_API_KEY=$(nrelApiKey) + pytest pvlib --junitxml=junit/test-results.xml --cov=com --cov-report=xml --cov-report=html displayName: 'Test with pytest' - task: PublishTestResults@2 @@ -75,6 +75,7 @@ jobs: displayName: 'List installed dependencies' - script: | source activate test_env + export NREL_API_KEY=$(nrelApiKey) pytest pvlib --junitxml=junit/test-results.xml --cov --cov-report=xml --cov-report=html displayName: 'pytest' # - script: | @@ -127,6 +128,7 @@ jobs: displayName: 'List installed dependencies' - script: | call activate test_env + export NREL_API_KEY=$(nrelApiKey) pytest pvlib --junitxml=junit/test-results.xml displayName: 'pytest' - task: PublishTestResults@2 @@ -156,6 +158,7 @@ jobs: - script: | pip install pytest pytest-cov pytest-mock pytest-timeout pytest-azurepipelines pip install -e . + export NREL_API_KEY=$(nrelApiKey) pytest pvlib --junitxml=junit/test-results.xml --cov=pvlib --cov-report=xml --cov-report=html displayName: 'Test with pytest' From 4f59d273c0fa2e61428e49f629e94125d845e0f4 Mon Sep 17 00:00:00 2001 From: Cameron Stark Date: Wed, 29 Jan 2020 13:38:23 -0700 Subject: [PATCH 39/69] add description to whatsnew --- docs/sphinx/source/whatsnew/v0.7.2.rst | 3 +++ 1 file changed, 3 insertions(+) diff --git a/docs/sphinx/source/whatsnew/v0.7.2.rst b/docs/sphinx/source/whatsnew/v0.7.2.rst index abd4771101..b5e3122ad3 100644 --- a/docs/sphinx/source/whatsnew/v0.7.2.rst +++ b/docs/sphinx/source/whatsnew/v0.7.2.rst @@ -13,6 +13,8 @@ Bug fixes ~~~~~~~~~ * Fix :py:func:`~pvlib.iotools.read_tmy3` parsing when February contains a leap year (:pull:`866`) +* Implement NREL Developer Network API key for consistent success with API + calls in :py:mod:`pvlib.tests.iotools.test_psm3` (:pull:`873`) Documentation ~~~~~~~~~~~~~ @@ -21,3 +23,4 @@ Documentation Contributors ~~~~~~~~~~~~ * Mark Mikofski (:ghuser:`mikofski`) +* Cameron T. Stark (:ghuser:`camerontstark`) From 51965e255a90bc0abece8ece568960e8d63729b0 Mon Sep 17 00:00:00 2001 From: Cameron Stark Date: Wed, 29 Jan 2020 13:46:51 -0700 Subject: [PATCH 40/69] formatting fix --- pvlib/tests/iotools/test_psm3.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pvlib/tests/iotools/test_psm3.py b/pvlib/tests/iotools/test_psm3.py index 6fe929fad5..0003d0405b 100644 --- a/pvlib/tests/iotools/test_psm3.py +++ b/pvlib/tests/iotools/test_psm3.py @@ -120,8 +120,8 @@ def test_get_psm3_singleyear(): delay_get_psm3(51, -5, DEMO_KEY, PVLIB_EMAIL, names='2017') with pytest.raises(HTTPError): # intervals can only be 30 or 60 minutes - delay_get_psm3(LATITUDE, LONGITUDE, DEMO_KEY, PVLIB_EMAIL, names='2017', - interval=15) + delay_get_psm3(LATITUDE, LONGITUDE, DEMO_KEY, PVLIB_EMAIL, + names='2017', interval=15) @pytest.fixture From 13045fb90a1e5db685b897f16ba7ba7fe3792b1b Mon Sep 17 00:00:00 2001 From: Cameron Stark Date: Wed, 29 Jan 2020 15:00:54 -0700 Subject: [PATCH 41/69] logger module implementation --- pvlib/tests/iotools/test_psm3.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/pvlib/tests/iotools/test_psm3.py b/pvlib/tests/iotools/test_psm3.py index 0003d0405b..0a1402e7e8 100644 --- a/pvlib/tests/iotools/test_psm3.py +++ b/pvlib/tests/iotools/test_psm3.py @@ -11,6 +11,11 @@ from requests import HTTPError from io import StringIO import time +import logging + +logging.basicConfig() +LOGGER = logging.getLogger(__name__) +LOGGER.setLevel(logging.WARNING) TMY_TEST_DATA = DATA_DIR / 'test_psm3_tmy-2017.csv' YEAR_TEST_DATA = DATA_DIR / 'test_psm3_2017.csv' @@ -26,8 +31,8 @@ try: DEMO_KEY = os.environ["NREL_API_KEY"] except KeyError: - print("WARNING: NREL API KEY environment variable not set!") - print("Using DEMO_KEY instead. This may cause unexpected failures.") + LOGGER.warning("WARNING: NREL API KEY environment variable not set!") + LOGGER.warning("Using DEMO_KEY instead. This may cause unexpected failures.") DEMO_KEY = 'DEMO_KEY' From 6358642248931114a658616c547dd0cf58fa9c19 Mon Sep 17 00:00:00 2001 From: Cameron Stark Date: Wed, 29 Jan 2020 16:04:44 -0700 Subject: [PATCH 42/69] more formatting --- pvlib/tests/iotools/test_psm3.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/pvlib/tests/iotools/test_psm3.py b/pvlib/tests/iotools/test_psm3.py index 0a1402e7e8..c406e2583b 100644 --- a/pvlib/tests/iotools/test_psm3.py +++ b/pvlib/tests/iotools/test_psm3.py @@ -32,7 +32,7 @@ DEMO_KEY = os.environ["NREL_API_KEY"] except KeyError: LOGGER.warning("WARNING: NREL API KEY environment variable not set!") - LOGGER.warning("Using DEMO_KEY instead. This may cause unexpected failures.") + LOGGER.warning("Using DEMO_KEY instead. Unexpected failures may occur.") DEMO_KEY = 'DEMO_KEY' @@ -89,7 +89,7 @@ def delay_get_psm3(*args, **kwargs): def test_get_psm3_tmy(): """test get_psm3 with a TMY""" header, data = delay_get_psm3(LATITUDE, LONGITUDE, DEMO_KEY, PVLIB_EMAIL, - names='tmy-2017') + names='tmy-2017') expected = pd.read_csv(TMY_TEST_DATA) assert_psm3_equal(header, data, expected) # check errors @@ -108,25 +108,25 @@ def test_get_psm3_tmy(): def test_get_psm3_singleyear(): """test get_psm3 with a single year""" header, data = delay_get_psm3(LATITUDE, LONGITUDE, DEMO_KEY, PVLIB_EMAIL, - names='2017', interval=30) + names='2017', interval=30) expected = pd.read_csv(YEAR_TEST_DATA) assert_psm3_equal(header, data, expected) # check leap day _, data_2012 = delay_get_psm3(LATITUDE, LONGITUDE, DEMO_KEY, PVLIB_EMAIL, - names='2012', interval=60, leap_day=True) + names='2012', interval=60, leap_day=True) assert len(data_2012) == (8760+24) # check errors with pytest.raises(HTTPError): # HTTP 403 forbidden because api_key is rejected delay_get_psm3(LATITUDE, LONGITUDE, api_key='BAD', email=PVLIB_EMAIL, - names='2017') + names='2017') with pytest.raises(HTTPError): # coordinates were not found in the NSRDB delay_get_psm3(51, -5, DEMO_KEY, PVLIB_EMAIL, names='2017') with pytest.raises(HTTPError): # intervals can only be 30 or 60 minutes delay_get_psm3(LATITUDE, LONGITUDE, DEMO_KEY, PVLIB_EMAIL, - names='2017', interval=15) + names='2017', interval=15) @pytest.fixture From efe0f1c6875915e9e75009d90ea9856c795939d5 Mon Sep 17 00:00:00 2001 From: Cameron Stark Date: Wed, 29 Jan 2020 16:31:28 -0700 Subject: [PATCH 43/69] change while loop to for loop --- pvlib/tests/iotools/test_psm3.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/pvlib/tests/iotools/test_psm3.py b/pvlib/tests/iotools/test_psm3.py index c406e2583b..492bf3d46e 100644 --- a/pvlib/tests/iotools/test_psm3.py +++ b/pvlib/tests/iotools/test_psm3.py @@ -67,8 +67,8 @@ def delay_get_psm3(*args, **kwargs): every OVER_RATE_LIMIT HTTPError in a row. Return (header, data) from get_psm3() as normal. """ - sleep_time = 0 - while True: + max_retries = 5 + for sleep_time in range(max_retries): try: # execute get_psm3 header, data = psm3.get_psm3(*args, **kwargs) @@ -76,7 +76,6 @@ def delay_get_psm3(*args, **kwargs): if "OVER_RATE_LIMIT" in str(e): # retry command after sleeping for a time time.sleep(sleep_time) - sleep_time += 1 continue # raise HTTPError if not due to OVER_RATE_LIMIT raise From 65c2d75a18a2fdccf00d3275b71333117b62234a Mon Sep 17 00:00:00 2001 From: Cameron Stark Date: Wed, 29 Jan 2020 16:53:18 -0700 Subject: [PATCH 44/69] use warnings instead of logging --- pvlib/tests/iotools/test_psm3.py | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/pvlib/tests/iotools/test_psm3.py b/pvlib/tests/iotools/test_psm3.py index 492bf3d46e..7478b21655 100644 --- a/pvlib/tests/iotools/test_psm3.py +++ b/pvlib/tests/iotools/test_psm3.py @@ -11,11 +11,7 @@ from requests import HTTPError from io import StringIO import time -import logging - -logging.basicConfig() -LOGGER = logging.getLogger(__name__) -LOGGER.setLevel(logging.WARNING) +import warnings TMY_TEST_DATA = DATA_DIR / 'test_psm3_tmy-2017.csv' YEAR_TEST_DATA = DATA_DIR / 'test_psm3_2017.csv' @@ -31,8 +27,10 @@ try: DEMO_KEY = os.environ["NREL_API_KEY"] except KeyError: - LOGGER.warning("WARNING: NREL API KEY environment variable not set!") - LOGGER.warning("Using DEMO_KEY instead. Unexpected failures may occur.") + warnings.warn( + "WARNING: NREL API KEY environment variable not set!" + "Using DEMO_KEY instead. Unexpected failures may occur." + ) DEMO_KEY = 'DEMO_KEY' From b9981c4516d2af999f1f86de04ac01015559409b Mon Sep 17 00:00:00 2001 From: Cameron Stark Date: Wed, 29 Jan 2020 17:29:42 -0700 Subject: [PATCH 45/69] fixturize DEMO_KEY --- pvlib/tests/iotools/test_psm3.py | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/pvlib/tests/iotools/test_psm3.py b/pvlib/tests/iotools/test_psm3.py index 7478b21655..3645f8ef5d 100644 --- a/pvlib/tests/iotools/test_psm3.py +++ b/pvlib/tests/iotools/test_psm3.py @@ -24,14 +24,20 @@ 'Temperature Units', 'Pressure Units', 'Wind Direction Units', 'Wind Speed', 'Surface Albedo Units', 'Version'] PVLIB_EMAIL = 'pvlib-admin@googlegroups.com' -try: - DEMO_KEY = os.environ["NREL_API_KEY"] -except KeyError: - warnings.warn( - "WARNING: NREL API KEY environment variable not set!" - "Using DEMO_KEY instead. Unexpected failures may occur." - ) - DEMO_KEY = 'DEMO_KEY' + + +@pytest.fixture(scope="module") +def DEMO_KEY(): + """""" + try: + demo_key = os.environ["NREL_API_KEY"] + except KeyError: + warnings.warn( + "WARNING: NREL API KEY environment variable not set! " + "Using DEMO_KEY instead. Unexpected failures may occur." + ) + demo_key = 'DEMO_KEY' + return demo_key def assert_psm3_equal(header, data, expected): From 5d7c587bf3e98302c0ca2155fbd11a198b5fb103 Mon Sep 17 00:00:00 2001 From: Cameron Stark Date: Thu, 30 Jan 2020 08:34:45 -0700 Subject: [PATCH 46/69] implement use of pytest-rerunfailures instead of custom loop --- pvlib/tests/iotools/test_psm3.py | 95 ++++++++++++++------------------ setup.py | 2 +- 2 files changed, 43 insertions(+), 54 deletions(-) diff --git a/pvlib/tests/iotools/test_psm3.py b/pvlib/tests/iotools/test_psm3.py index 3645f8ef5d..345b845a24 100644 --- a/pvlib/tests/iotools/test_psm3.py +++ b/pvlib/tests/iotools/test_psm3.py @@ -10,7 +10,6 @@ import pytest from requests import HTTPError from io import StringIO -import time import warnings TMY_TEST_DATA = DATA_DIR / 'test_psm3_tmy-2017.csv' @@ -65,71 +64,61 @@ def assert_psm3_equal(header, data, expected): assert (data.index.tzinfo.zone == 'Etc/GMT%+d' % -header['Time Zone']) -def delay_get_psm3(*args, **kwargs): - """Repeat get_psm3() call if OVER_RATE_LIMIT error occurs otherwise - allow HTTPError to raise. Sleep times increase by one second for - every OVER_RATE_LIMIT HTTPError in a row. Return (header, data) from - get_psm3() as normal. - """ - max_retries = 5 - for sleep_time in range(max_retries): - try: - # execute get_psm3 - header, data = psm3.get_psm3(*args, **kwargs) - except HTTPError as e: - if "OVER_RATE_LIMIT" in str(e): - # retry command after sleeping for a time - time.sleep(sleep_time) - continue - # raise HTTPError if not due to OVER_RATE_LIMIT - raise - else: - break - return header, data - - @needs_pandas_0_22 -def test_get_psm3_tmy(): +@pytest.mark.flaky(reruns=5, reruns_delay=2) +def test_get_psm3_tmy(DEMO_KEY): """test get_psm3 with a TMY""" - header, data = delay_get_psm3(LATITUDE, LONGITUDE, DEMO_KEY, PVLIB_EMAIL, - names='tmy-2017') + header, data = psm3.get_psm3(LATITUDE, LONGITUDE, DEMO_KEY, PVLIB_EMAIL, + names='tmy-2017') expected = pd.read_csv(TMY_TEST_DATA) assert_psm3_equal(header, data, expected) - # check errors - with pytest.raises(HTTPError): - # HTTP 403 forbidden because api_key is rejected - delay_get_psm3(LATITUDE, LONGITUDE, api_key='BAD', email=PVLIB_EMAIL) - with pytest.raises(HTTPError): - # coordinates were not found in the NSRDB - delay_get_psm3(51, -5, DEMO_KEY, PVLIB_EMAIL) - with pytest.raises(HTTPError): - # names is not one of the available options - delay_get_psm3(LATITUDE, LONGITUDE, DEMO_KEY, PVLIB_EMAIL, names='bad') @needs_pandas_0_22 -def test_get_psm3_singleyear(): +@pytest.mark.flaky(reruns=5, reruns_delay=2) +def test_get_psm3_singleyear(DEMO_KEY): """test get_psm3 with a single year""" - header, data = delay_get_psm3(LATITUDE, LONGITUDE, DEMO_KEY, PVLIB_EMAIL, - names='2017', interval=30) + header, data = psm3.get_psm3(LATITUDE, LONGITUDE, DEMO_KEY, PVLIB_EMAIL, + names='2017', interval=30) expected = pd.read_csv(YEAR_TEST_DATA) assert_psm3_equal(header, data, expected) - # check leap day - _, data_2012 = delay_get_psm3(LATITUDE, LONGITUDE, DEMO_KEY, PVLIB_EMAIL, - names='2012', interval=60, leap_day=True) - assert len(data_2012) == (8760+24) - # check errors - with pytest.raises(HTTPError): + + +@needs_pandas_0_22 +@pytest.mark.flaky(reruns=5, reruns_delay=2) +def test_get_psm3_tmy_bad_api(DEMO_KEY): + with pytest.raises(HTTPError) as e: # HTTP 403 forbidden because api_key is rejected - delay_get_psm3(LATITUDE, LONGITUDE, api_key='BAD', email=PVLIB_EMAIL, - names='2017') - with pytest.raises(HTTPError): + psm3.get_psm3(LATITUDE, LONGITUDE, api_key='BAD', email=PVLIB_EMAIL) + assert "OVER_RATE_LIMIT" not in str(e.value) + + +@needs_pandas_0_22 +@pytest.mark.flaky(reruns=5, reruns_delay=2) +def test_get_psm3_tmy_bad_coordinates(DEMO_KEY): + with pytest.raises(HTTPError) as e: # coordinates were not found in the NSRDB - delay_get_psm3(51, -5, DEMO_KEY, PVLIB_EMAIL, names='2017') - with pytest.raises(HTTPError): + psm3.get_psm3(51, -5, DEMO_KEY, PVLIB_EMAIL) + assert "OVER_RATE_LIMIT" not in str(e.value) + + +@needs_pandas_0_22 +@pytest.mark.flaky(reruns=5, reruns_delay=2) +def test_get_psm3_tmy_bad_names(DEMO_KEY): + with pytest.raises(HTTPError) as e: + # names is not one of the available options + psm3.get_psm3(LATITUDE, LONGITUDE, DEMO_KEY, PVLIB_EMAIL, names='bad') + assert "OVER_RATE_LIMIT" not in str(e.value) + + +@needs_pandas_0_22 +@pytest.mark.flaky(reruns=5, reruns_delay=2) +def test_get_psm3_tmy_bad_interval(DEMO_KEY): + with pytest.raises(HTTPError) as e: # intervals can only be 30 or 60 minutes - delay_get_psm3(LATITUDE, LONGITUDE, DEMO_KEY, PVLIB_EMAIL, - names='2017', interval=15) + psm3.get_psm3(LATITUDE, LONGITUDE, DEMO_KEY, PVLIB_EMAIL, + names='2017', interval=15) + assert "OVER_RATE_LIMIT" not in str(e.value) @pytest.fixture diff --git a/setup.py b/setup.py index b52a8ce731..df8201c0ba 100755 --- a/setup.py +++ b/setup.py @@ -42,7 +42,7 @@ 'pytz', 'requests'] TESTS_REQUIRE = ['nose', 'pytest', 'pytest-cov', 'pytest-mock', - 'pytest-timeout'] + 'pytest-timeout', 'pytest-rerunfailures'] EXTRAS_REQUIRE = { 'optional': ['ephem', 'cython', 'netcdf4', 'nrel-pysam', 'numba', 'pvfactors', 'scipy', 'siphon', 'tables'], From 0963441d4fd76297ef118a3536c4511eed90e441 Mon Sep 17 00:00:00 2001 From: Cameron Stark Date: Thu, 30 Jan 2020 08:48:58 -0700 Subject: [PATCH 47/69] parametrize error tests into a signle test --- pvlib/tests/iotools/test_psm3.py | 49 ++++++++++++-------------------- 1 file changed, 18 insertions(+), 31 deletions(-) diff --git a/pvlib/tests/iotools/test_psm3.py b/pvlib/tests/iotools/test_psm3.py index 345b845a24..acf23f39f5 100644 --- a/pvlib/tests/iotools/test_psm3.py +++ b/pvlib/tests/iotools/test_psm3.py @@ -84,40 +84,27 @@ def test_get_psm3_singleyear(DEMO_KEY): assert_psm3_equal(header, data, expected) +@pytest.mark.parametrize('latitude, longitude, api_key, names, interval', + [(LATITUDE, LONGITUDE, 'BAD', 'tmy-2017', 60), + (51, -5, DEMO_KEY, 'tmy-2017', 60), + (LATITUDE, LONGITUDE, DEMO_KEY, 'bad', 60), + (LATITUDE, LONGITUDE, DEMO_KEY, '2017', 15), + ]) @needs_pandas_0_22 @pytest.mark.flaky(reruns=5, reruns_delay=2) -def test_get_psm3_tmy_bad_api(DEMO_KEY): +def test_get_psm3_tmy_errors( + DEMO_KEY, latitude, longitude, api_key, names, interval +): + """Test get_psm3() for multiple error scenarios: + * Bad api key -> HTTP 403 forbidden because api_key is rejected + * Bad latitude/longitude -> Coordinates were not found in the NSRDB + * Bad name -> names is not one of the available options + * Bad interval, single year -> intervals can only be 30 or 60 minutes + """ with pytest.raises(HTTPError) as e: - # HTTP 403 forbidden because api_key is rejected - psm3.get_psm3(LATITUDE, LONGITUDE, api_key='BAD', email=PVLIB_EMAIL) - assert "OVER_RATE_LIMIT" not in str(e.value) - - -@needs_pandas_0_22 -@pytest.mark.flaky(reruns=5, reruns_delay=2) -def test_get_psm3_tmy_bad_coordinates(DEMO_KEY): - with pytest.raises(HTTPError) as e: - # coordinates were not found in the NSRDB - psm3.get_psm3(51, -5, DEMO_KEY, PVLIB_EMAIL) - assert "OVER_RATE_LIMIT" not in str(e.value) - - -@needs_pandas_0_22 -@pytest.mark.flaky(reruns=5, reruns_delay=2) -def test_get_psm3_tmy_bad_names(DEMO_KEY): - with pytest.raises(HTTPError) as e: - # names is not one of the available options - psm3.get_psm3(LATITUDE, LONGITUDE, DEMO_KEY, PVLIB_EMAIL, names='bad') - assert "OVER_RATE_LIMIT" not in str(e.value) - - -@needs_pandas_0_22 -@pytest.mark.flaky(reruns=5, reruns_delay=2) -def test_get_psm3_tmy_bad_interval(DEMO_KEY): - with pytest.raises(HTTPError) as e: - # intervals can only be 30 or 60 minutes - psm3.get_psm3(LATITUDE, LONGITUDE, DEMO_KEY, PVLIB_EMAIL, - names='2017', interval=15) + psm3.get_psm3(latitude, longitude, api_key, PVLIB_EMAIL, + names=names, interval=interval) + # ensure the HTTPError caught isn't due to overuse of the API key assert "OVER_RATE_LIMIT" not in str(e.value) From ef56cceeb858b5a3a1003a64e2afc6dc45951b37 Mon Sep 17 00:00:00 2001 From: Cameron Stark Date: Thu, 30 Jan 2020 09:54:40 -0700 Subject: [PATCH 48/69] fix windows environment import of NREL key --- azure-pipelines.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 622b1dde70..a164c7299d 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -128,7 +128,7 @@ jobs: displayName: 'List installed dependencies' - script: | call activate test_env - export NREL_API_KEY=$(nrelApiKey) + set NREL_API_KEY=%nrelApiKey% pytest pvlib --junitxml=junit/test-results.xml displayName: 'pytest' - task: PublishTestResults@2 From 09b0af665919d1fdcf3d8db297eafa06603e1f73 Mon Sep 17 00:00:00 2001 From: Cameron Stark Date: Thu, 30 Jan 2020 09:56:12 -0700 Subject: [PATCH 49/69] test to echo environment variable of NREL key --- azure-pipelines.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index a164c7299d..9d5839e332 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -28,6 +28,7 @@ jobs: pip install pytest pytest-cov pytest-mock pytest-timeout pytest-azurepipelines pip install -e . export NREL_API_KEY=$(nrelApiKey) + echo $NREL_API_KEY pytest pvlib --junitxml=junit/test-results.xml --cov=com --cov-report=xml --cov-report=html displayName: 'Test with pytest' @@ -76,6 +77,7 @@ jobs: - script: | source activate test_env export NREL_API_KEY=$(nrelApiKey) + echo $NREL_API_KEY pytest pvlib --junitxml=junit/test-results.xml --cov --cov-report=xml --cov-report=html displayName: 'pytest' # - script: | @@ -129,6 +131,7 @@ jobs: - script: | call activate test_env set NREL_API_KEY=%nrelApiKey% + echo %NREL_API_KEY% pytest pvlib --junitxml=junit/test-results.xml displayName: 'pytest' - task: PublishTestResults@2 @@ -159,6 +162,7 @@ jobs: pip install pytest pytest-cov pytest-mock pytest-timeout pytest-azurepipelines pip install -e . export NREL_API_KEY=$(nrelApiKey) + echo $NREL_API_KEY pytest pvlib --junitxml=junit/test-results.xml --cov=pvlib --cov-report=xml --cov-report=html displayName: 'Test with pytest' From 8db513db75b6ee3ef8bcc0b7ef60f449da61872d Mon Sep 17 00:00:00 2001 From: Cameron Stark Date: Thu, 30 Jan 2020 16:10:04 -0700 Subject: [PATCH 50/69] fix windows secret variable setting --- azure-pipelines.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 9d5839e332..1f2a5c2f7f 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -130,7 +130,7 @@ jobs: displayName: 'List installed dependencies' - script: | call activate test_env - set NREL_API_KEY=%nrelApiKey% + set NREL_API_KEY=$(nrelApiKey) echo %NREL_API_KEY% pytest pvlib --junitxml=junit/test-results.xml displayName: 'pytest' From 89c5af34b46e9db7ccf4effec4c26481668f0b90 Mon Sep 17 00:00:00 2001 From: Cameron Stark Date: Mon, 3 Feb 2020 15:12:41 -0700 Subject: [PATCH 51/69] add pytest-rerunfailures to ci requirements yml --- ci/requirements-py35-min.yml | 1 + ci/requirements-py35.yml | 1 + ci/requirements-py36.yml | 1 + ci/requirements-py37.yml | 1 + 4 files changed, 4 insertions(+) diff --git a/ci/requirements-py35-min.yml b/ci/requirements-py35-min.yml index fc39936c05..0a1b16b1b7 100644 --- a/ci/requirements-py35-min.yml +++ b/ci/requirements-py35-min.yml @@ -9,6 +9,7 @@ dependencies: - pytest-cov - pytest-mock - pytest-timeout + - pytest-rerunfailures - python=3.5 - pytz - requests diff --git a/ci/requirements-py35.yml b/ci/requirements-py35.yml index 5fc0077991..2da7935ebb 100644 --- a/ci/requirements-py35.yml +++ b/ci/requirements-py35.yml @@ -17,6 +17,7 @@ dependencies: - pytest-cov - pytest-mock - pytest-timeout + - pytest-rerunfailures - python=3.5 - pytz - requests diff --git a/ci/requirements-py36.yml b/ci/requirements-py36.yml index e415f67c7d..863b84a759 100644 --- a/ci/requirements-py36.yml +++ b/ci/requirements-py36.yml @@ -16,6 +16,7 @@ dependencies: - pytest - pytest-cov - pytest-mock + - pytest-rerunfailures - pytest-timeout - python=3.6 - pytz diff --git a/ci/requirements-py37.yml b/ci/requirements-py37.yml index 1a6809fba6..0a8f1f913f 100644 --- a/ci/requirements-py37.yml +++ b/ci/requirements-py37.yml @@ -17,6 +17,7 @@ dependencies: - pytest-cov - pytest-mock - pytest-timeout + - pytest-rerunfailures - python=3.7 - pytz - requests From 9aeabf86d4eef451f9257879531a97a2d6ace4a4 Mon Sep 17 00:00:00 2001 From: Cameron Stark Date: Mon, 3 Feb 2020 17:52:24 -0700 Subject: [PATCH 52/69] use secret.nrelApiKey syntax --- azure-pipelines.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 1f2a5c2f7f..c30a77caed 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -27,7 +27,7 @@ jobs: - script: | pip install pytest pytest-cov pytest-mock pytest-timeout pytest-azurepipelines pip install -e . - export NREL_API_KEY=$(nrelApiKey) + export NREL_API_KEY=$(secret.nrelApiKey) echo $NREL_API_KEY pytest pvlib --junitxml=junit/test-results.xml --cov=com --cov-report=xml --cov-report=html displayName: 'Test with pytest' From 6646a2e8a9d196742543225c9746f29254138b7e Mon Sep 17 00:00:00 2001 From: Cameron Stark Date: Tue, 4 Feb 2020 10:22:39 -0700 Subject: [PATCH 53/69] test new secret variable --- azure-pipelines.yml | 298 ++++++++++++++++++++++---------------------- 1 file changed, 149 insertions(+), 149 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index c30a77caed..82e6d3035d 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -27,8 +27,8 @@ jobs: - script: | pip install pytest pytest-cov pytest-mock pytest-timeout pytest-azurepipelines pip install -e . - export NREL_API_KEY=$(secret.nrelApiKey) - echo $NREL_API_KEY + export NREL_API_KEY=$(api_key) + echo "This is the key: $NREL_API_KEY" pytest pvlib --junitxml=junit/test-results.xml --cov=com --cov-report=xml --cov-report=html displayName: 'Test with pytest' @@ -45,150 +45,150 @@ jobs: reportDirectory: '$(System.DefaultWorkingDirectory)/**/htmlcov' -- job: 'Test_conda_linux' - - pool: - vmImage: 'ubuntu-16.04' - - strategy: - matrix: - Python35: - python.version: '35' - Python36: - python.version: '36' - coverage: true - Python37: - python.version: '37' - - steps: - - bash: echo "##vso[task.prependpath]/usr/share/miniconda/bin" - displayName: Add conda to PATH - - script: conda env create --quiet --file ci/requirements-py$(python.version).yml - displayName: Create Anaconda environment - - script: | - source activate test_env - pip install pytest-azurepipelines - pip install -e . - displayName: 'pip dependencies' - - script: | - source activate test_env - conda list - displayName: 'List installed dependencies' - - script: | - source activate test_env - export NREL_API_KEY=$(nrelApiKey) - echo $NREL_API_KEY - pytest pvlib --junitxml=junit/test-results.xml --cov --cov-report=xml --cov-report=html - displayName: 'pytest' - # - script: | - # source activate test_env - # flake8 pvlib - # displayName: 'flake8' - - task: PublishTestResults@2 - inputs: - testResultsFiles: '**/test-results.xml' - testRunTitle: 'Linux $(python.version)' - - task: PublishCodeCoverageResults@1 - inputs: - codeCoverageTool: Cobertura - summaryFileLocation: '$(System.DefaultWorkingDirectory)/**/coverage.xml' - reportDirectory: '$(System.DefaultWorkingDirectory)/**/htmlcov' - condition: eq(variables['coverage'], true) - - script: | - bash <(curl https://codecov.io/bash) -t bbc2bdbe-5e67-4fef-9cb7-f52fe0b703a8 -f coverage.xml -F adder -F subtractor -F conda - displayName: 'codecov' - condition: eq(variables['coverage'], true) - - -- job: 'Test_conda_windows' - - pool: - vmImage: 'vs2017-win2016' - - strategy: - matrix: - Python35-windows: - python.version: '35' - Python36-windows: - python.version: '36' - Python37-windows: - python.version: '37' - - steps: - - powershell: Write-Host "##vso[task.prependpath]$env:CONDA\Scripts" - displayName: Add conda to PATH - - script: conda env create --quiet --file ci/requirements-py$(python.version).yml - displayName: Create Anaconda environment - - script: | - call activate test_env - pip install pytest-azurepipelines - pip install -e . - displayName: 'pip dependencies' - - script: | - call activate test_env - conda list - displayName: 'List installed dependencies' - - script: | - call activate test_env - set NREL_API_KEY=$(nrelApiKey) - echo %NREL_API_KEY% - pytest pvlib --junitxml=junit/test-results.xml - displayName: 'pytest' - - task: PublishTestResults@2 - inputs: - testResultsFiles: '**/test-results.xml' - testRunTitle: 'Windows $(python.version)' - - -- job: 'Test_bare_macOS_Mojave' - - pool: - vmImage: 'macOS-10.14' - strategy: - matrix: - Python35: - python.version: '3.5' - Python36: - python.version: '3.6' - Python37: - python.version: '3.7' - - steps: - - task: UsePythonVersion@0 - inputs: - versionSpec: '$(python.version)' - - - script: | - pip install pytest pytest-cov pytest-mock pytest-timeout pytest-azurepipelines - pip install -e . - export NREL_API_KEY=$(nrelApiKey) - echo $NREL_API_KEY - pytest pvlib --junitxml=junit/test-results.xml --cov=pvlib --cov-report=xml --cov-report=html - displayName: 'Test with pytest' - - - task: PublishTestResults@2 - condition: succeededOrFailed() - inputs: - testResultsFiles: '**/test-*.xml' - testRunTitle: 'Publish test results for Python $(python.version)' - - - task: PublishCodeCoverageResults@1 - inputs: - codeCoverageTool: Cobertura - summaryFileLocation: '$(System.DefaultWorkingDirectory)/**/coverage.xml' - reportDirectory: '$(System.DefaultWorkingDirectory)/**/htmlcov' - - -- job: 'Publish' - dependsOn: 'Test_conda_linux' - pool: - vmImage: 'ubuntu-latest' - - steps: - - task: UsePythonVersion@0 - inputs: - versionSpec: '3.x' - architecture: 'x64' - - - script: python setup.py sdist - displayName: 'Build sdist' +# - job: 'Test_conda_linux' + +# pool: +# vmImage: 'ubuntu-16.04' + +# strategy: +# matrix: +# Python35: +# python.version: '35' +# Python36: +# python.version: '36' +# coverage: true +# Python37: +# python.version: '37' + +# steps: +# - bash: echo "##vso[task.prependpath]/usr/share/miniconda/bin" +# displayName: Add conda to PATH +# - script: conda env create --quiet --file ci/requirements-py$(python.version).yml +# displayName: Create Anaconda environment +# - script: | +# source activate test_env +# pip install pytest-azurepipelines +# pip install -e . +# displayName: 'pip dependencies' +# - script: | +# source activate test_env +# conda list +# displayName: 'List installed dependencies' +# - script: | +# source activate test_env +# export NREL_API_KEY=$(nrelApiKey) +# echo $NREL_API_KEY +# pytest pvlib --junitxml=junit/test-results.xml --cov --cov-report=xml --cov-report=html +# displayName: 'pytest' +# # - script: | +# # source activate test_env +# # flake8 pvlib +# # displayName: 'flake8' +# - task: PublishTestResults@2 +# inputs: +# testResultsFiles: '**/test-results.xml' +# testRunTitle: 'Linux $(python.version)' +# - task: PublishCodeCoverageResults@1 +# inputs: +# codeCoverageTool: Cobertura +# summaryFileLocation: '$(System.DefaultWorkingDirectory)/**/coverage.xml' +# reportDirectory: '$(System.DefaultWorkingDirectory)/**/htmlcov' +# condition: eq(variables['coverage'], true) +# - script: | +# bash <(curl https://codecov.io/bash) -t bbc2bdbe-5e67-4fef-9cb7-f52fe0b703a8 -f coverage.xml -F adder -F subtractor -F conda +# displayName: 'codecov' +# condition: eq(variables['coverage'], true) + + +# - job: 'Test_conda_windows' + +# pool: +# vmImage: 'vs2017-win2016' + +# strategy: +# matrix: +# Python35-windows: +# python.version: '35' +# Python36-windows: +# python.version: '36' +# Python37-windows: +# python.version: '37' + +# steps: +# - powershell: Write-Host "##vso[task.prependpath]$env:CONDA\Scripts" +# displayName: Add conda to PATH +# - script: conda env create --quiet --file ci/requirements-py$(python.version).yml +# displayName: Create Anaconda environment +# - script: | +# call activate test_env +# pip install pytest-azurepipelines +# pip install -e . +# displayName: 'pip dependencies' +# - script: | +# call activate test_env +# conda list +# displayName: 'List installed dependencies' +# - script: | +# call activate test_env +# set NREL_API_KEY=$(nrelApiKey) +# echo %NREL_API_KEY% +# pytest pvlib --junitxml=junit/test-results.xml +# displayName: 'pytest' +# - task: PublishTestResults@2 +# inputs: +# testResultsFiles: '**/test-results.xml' +# testRunTitle: 'Windows $(python.version)' + + +# - job: 'Test_bare_macOS_Mojave' + +# pool: +# vmImage: 'macOS-10.14' +# strategy: +# matrix: +# Python35: +# python.version: '3.5' +# Python36: +# python.version: '3.6' +# Python37: +# python.version: '3.7' + +# steps: +# - task: UsePythonVersion@0 +# inputs: +# versionSpec: '$(python.version)' + +# - script: | +# pip install pytest pytest-cov pytest-mock pytest-timeout pytest-azurepipelines +# pip install -e . +# export NREL_API_KEY=$(nrelApiKey) +# echo $NREL_API_KEY +# pytest pvlib --junitxml=junit/test-results.xml --cov=pvlib --cov-report=xml --cov-report=html +# displayName: 'Test with pytest' + +# - task: PublishTestResults@2 +# condition: succeededOrFailed() +# inputs: +# testResultsFiles: '**/test-*.xml' +# testRunTitle: 'Publish test results for Python $(python.version)' + +# - task: PublishCodeCoverageResults@1 +# inputs: +# codeCoverageTool: Cobertura +# summaryFileLocation: '$(System.DefaultWorkingDirectory)/**/coverage.xml' +# reportDirectory: '$(System.DefaultWorkingDirectory)/**/htmlcov' + + +# - job: 'Publish' +# dependsOn: 'Test_conda_linux' +# pool: +# vmImage: 'ubuntu-latest' + +# steps: +# - task: UsePythonVersion@0 +# inputs: +# versionSpec: '3.x' +# architecture: 'x64' + +# - script: python setup.py sdist +# displayName: 'Build sdist' From 075de57b180efbd48d56e73613e612b19cf07ce3 Mon Sep 17 00:00:00 2001 From: Cameron Stark Date: Tue, 4 Feb 2020 10:28:15 -0700 Subject: [PATCH 54/69] try secret.api_key syntax --- azure-pipelines.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 82e6d3035d..31952521d6 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -12,10 +12,10 @@ jobs: vmImage: 'ubuntu-16.04' strategy: matrix: - Python35: - python.version: '3.5' - Python36: - python.version: '3.6' + # Python35: + # python.version: '3.5' + # Python36: + # python.version: '3.6' Python37: python.version: '3.7' @@ -27,7 +27,7 @@ jobs: - script: | pip install pytest pytest-cov pytest-mock pytest-timeout pytest-azurepipelines pip install -e . - export NREL_API_KEY=$(api_key) + export NREL_API_KEY=$(secret.api_key) echo "This is the key: $NREL_API_KEY" pytest pvlib --junitxml=junit/test-results.xml --cov=com --cov-report=xml --cov-report=html displayName: 'Test with pytest' From 15a980dd0f35f24e283d9aeff0546b96d2bfb078 Mon Sep 17 00:00:00 2001 From: Cameron Stark Date: Tue, 4 Feb 2020 10:36:16 -0700 Subject: [PATCH 55/69] std syntax only psm3 --- azure-pipelines.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 31952521d6..9d2db6f102 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -27,9 +27,9 @@ jobs: - script: | pip install pytest pytest-cov pytest-mock pytest-timeout pytest-azurepipelines pip install -e . - export NREL_API_KEY=$(secret.api_key) + export NREL_API_KEY=$(api_key) echo "This is the key: $NREL_API_KEY" - pytest pvlib --junitxml=junit/test-results.xml --cov=com --cov-report=xml --cov-report=html + pytest pvlib/tests/iotools/test_psm3.py --junitxml=junit/test-results.xml --cov=com --cov-report=xml --cov-report=html displayName: 'Test with pytest' - task: PublishTestResults@2 From e49cba1bc63c9e3da066a9e6707050fc5fc0609c Mon Sep 17 00:00:00 2001 From: Cameron Stark Date: Tue, 4 Feb 2020 10:56:15 -0700 Subject: [PATCH 56/69] try to print other variables that arent secrets --- azure-pipelines.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 9d2db6f102..a02f4e20f9 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -27,6 +27,9 @@ jobs: - script: | pip install pytest pytest-cov pytest-mock pytest-timeout pytest-azurepipelines pip install -e . + export PRINT_ME=$(not_secret) + echo "print me: $PRINT_ME" + echo "direct print $(not_secret)" export NREL_API_KEY=$(api_key) echo "This is the key: $NREL_API_KEY" pytest pvlib/tests/iotools/test_psm3.py --junitxml=junit/test-results.xml --cov=com --cov-report=xml --cov-report=html From 76c9a5b2e227d6da0a7d68db29cf7ed2403aa106 Mon Sep 17 00:00:00 2001 From: Cameron Stark Date: Tue, 4 Feb 2020 11:15:15 -0700 Subject: [PATCH 57/69] confirm personal repo still works --- azure-pipelines.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index a02f4e20f9..8f0a60466e 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -30,7 +30,7 @@ jobs: export PRINT_ME=$(not_secret) echo "print me: $PRINT_ME" echo "direct print $(not_secret)" - export NREL_API_KEY=$(api_key) + export NREL_API_KEY=$(nrelApiKey) echo "This is the key: $NREL_API_KEY" pytest pvlib/tests/iotools/test_psm3.py --junitxml=junit/test-results.xml --cov=com --cov-report=xml --cov-report=html displayName: 'Test with pytest' From 4468bcbc4bcb4e86e71816a5c1d3f6483ecdb97b Mon Sep 17 00:00:00 2001 From: Cameron Stark Date: Tue, 4 Feb 2020 12:26:06 -0700 Subject: [PATCH 58/69] bump --- azure-pipelines.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 8f0a60466e..7ef433656b 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -19,6 +19,7 @@ jobs: Python37: python.version: '3.7' + steps: - task: UsePythonVersion@0 inputs: From 9927ef59f98dd1619ce69b2fc119f07bfacdabb1 Mon Sep 17 00:00:00 2001 From: Cameron Stark Date: Tue, 4 Feb 2020 12:30:34 -0700 Subject: [PATCH 59/69] try all python versions --- azure-pipelines.yml | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 7ef433656b..ace57fa06b 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -12,10 +12,10 @@ jobs: vmImage: 'ubuntu-16.04' strategy: matrix: - # Python35: - # python.version: '3.5' - # Python36: - # python.version: '3.6' + Python35: + python.version: '3.5' + Python36: + python.version: '3.6' Python37: python.version: '3.7' @@ -28,9 +28,6 @@ jobs: - script: | pip install pytest pytest-cov pytest-mock pytest-timeout pytest-azurepipelines pip install -e . - export PRINT_ME=$(not_secret) - echo "print me: $PRINT_ME" - echo "direct print $(not_secret)" export NREL_API_KEY=$(nrelApiKey) echo "This is the key: $NREL_API_KEY" pytest pvlib/tests/iotools/test_psm3.py --junitxml=junit/test-results.xml --cov=com --cov-report=xml --cov-report=html From e1b0959cb072a5a281e2f2b8ec31336c2e232a53 Mon Sep 17 00:00:00 2001 From: Cameron Stark Date: Tue, 4 Feb 2020 12:31:55 -0700 Subject: [PATCH 60/69] try everything --- azure-pipelines.yml | 296 ++++++++++++++++++++++---------------------- 1 file changed, 148 insertions(+), 148 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index ace57fa06b..2ecd50c52a 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -30,7 +30,7 @@ jobs: pip install -e . export NREL_API_KEY=$(nrelApiKey) echo "This is the key: $NREL_API_KEY" - pytest pvlib/tests/iotools/test_psm3.py --junitxml=junit/test-results.xml --cov=com --cov-report=xml --cov-report=html + pytest pvlib --junitxml=junit/test-results.xml --cov=com --cov-report=xml --cov-report=html displayName: 'Test with pytest' - task: PublishTestResults@2 @@ -46,150 +46,150 @@ jobs: reportDirectory: '$(System.DefaultWorkingDirectory)/**/htmlcov' -# - job: 'Test_conda_linux' - -# pool: -# vmImage: 'ubuntu-16.04' - -# strategy: -# matrix: -# Python35: -# python.version: '35' -# Python36: -# python.version: '36' -# coverage: true -# Python37: -# python.version: '37' - -# steps: -# - bash: echo "##vso[task.prependpath]/usr/share/miniconda/bin" -# displayName: Add conda to PATH -# - script: conda env create --quiet --file ci/requirements-py$(python.version).yml -# displayName: Create Anaconda environment -# - script: | -# source activate test_env -# pip install pytest-azurepipelines -# pip install -e . -# displayName: 'pip dependencies' -# - script: | -# source activate test_env -# conda list -# displayName: 'List installed dependencies' -# - script: | -# source activate test_env -# export NREL_API_KEY=$(nrelApiKey) -# echo $NREL_API_KEY -# pytest pvlib --junitxml=junit/test-results.xml --cov --cov-report=xml --cov-report=html -# displayName: 'pytest' -# # - script: | -# # source activate test_env -# # flake8 pvlib -# # displayName: 'flake8' -# - task: PublishTestResults@2 -# inputs: -# testResultsFiles: '**/test-results.xml' -# testRunTitle: 'Linux $(python.version)' -# - task: PublishCodeCoverageResults@1 -# inputs: -# codeCoverageTool: Cobertura -# summaryFileLocation: '$(System.DefaultWorkingDirectory)/**/coverage.xml' -# reportDirectory: '$(System.DefaultWorkingDirectory)/**/htmlcov' -# condition: eq(variables['coverage'], true) -# - script: | -# bash <(curl https://codecov.io/bash) -t bbc2bdbe-5e67-4fef-9cb7-f52fe0b703a8 -f coverage.xml -F adder -F subtractor -F conda -# displayName: 'codecov' -# condition: eq(variables['coverage'], true) - - -# - job: 'Test_conda_windows' - -# pool: -# vmImage: 'vs2017-win2016' - -# strategy: -# matrix: -# Python35-windows: -# python.version: '35' -# Python36-windows: -# python.version: '36' -# Python37-windows: -# python.version: '37' - -# steps: -# - powershell: Write-Host "##vso[task.prependpath]$env:CONDA\Scripts" -# displayName: Add conda to PATH -# - script: conda env create --quiet --file ci/requirements-py$(python.version).yml -# displayName: Create Anaconda environment -# - script: | -# call activate test_env -# pip install pytest-azurepipelines -# pip install -e . -# displayName: 'pip dependencies' -# - script: | -# call activate test_env -# conda list -# displayName: 'List installed dependencies' -# - script: | -# call activate test_env -# set NREL_API_KEY=$(nrelApiKey) -# echo %NREL_API_KEY% -# pytest pvlib --junitxml=junit/test-results.xml -# displayName: 'pytest' -# - task: PublishTestResults@2 -# inputs: -# testResultsFiles: '**/test-results.xml' -# testRunTitle: 'Windows $(python.version)' - - -# - job: 'Test_bare_macOS_Mojave' - -# pool: -# vmImage: 'macOS-10.14' -# strategy: -# matrix: -# Python35: -# python.version: '3.5' -# Python36: -# python.version: '3.6' -# Python37: -# python.version: '3.7' - -# steps: -# - task: UsePythonVersion@0 -# inputs: -# versionSpec: '$(python.version)' - -# - script: | -# pip install pytest pytest-cov pytest-mock pytest-timeout pytest-azurepipelines -# pip install -e . -# export NREL_API_KEY=$(nrelApiKey) -# echo $NREL_API_KEY -# pytest pvlib --junitxml=junit/test-results.xml --cov=pvlib --cov-report=xml --cov-report=html -# displayName: 'Test with pytest' - -# - task: PublishTestResults@2 -# condition: succeededOrFailed() -# inputs: -# testResultsFiles: '**/test-*.xml' -# testRunTitle: 'Publish test results for Python $(python.version)' - -# - task: PublishCodeCoverageResults@1 -# inputs: -# codeCoverageTool: Cobertura -# summaryFileLocation: '$(System.DefaultWorkingDirectory)/**/coverage.xml' -# reportDirectory: '$(System.DefaultWorkingDirectory)/**/htmlcov' - - -# - job: 'Publish' -# dependsOn: 'Test_conda_linux' -# pool: -# vmImage: 'ubuntu-latest' - -# steps: -# - task: UsePythonVersion@0 -# inputs: -# versionSpec: '3.x' -# architecture: 'x64' - -# - script: python setup.py sdist -# displayName: 'Build sdist' +- job: 'Test_conda_linux' + + pool: + vmImage: 'ubuntu-16.04' + + strategy: + matrix: + Python35: + python.version: '35' + Python36: + python.version: '36' + coverage: true + Python37: + python.version: '37' + + steps: + - bash: echo "##vso[task.prependpath]/usr/share/miniconda/bin" + displayName: Add conda to PATH + - script: conda env create --quiet --file ci/requirements-py$(python.version).yml + displayName: Create Anaconda environment + - script: | + source activate test_env + pip install pytest-azurepipelines + pip install -e . + displayName: 'pip dependencies' + - script: | + source activate test_env + conda list + displayName: 'List installed dependencies' + - script: | + source activate test_env + export NREL_API_KEY=$(nrelApiKey) + echo $NREL_API_KEY + pytest pvlib --junitxml=junit/test-results.xml --cov --cov-report=xml --cov-report=html + displayName: 'pytest' + # - script: | + # source activate test_env + # flake8 pvlib + # displayName: 'flake8' + - task: PublishTestResults@2 + inputs: + testResultsFiles: '**/test-results.xml' + testRunTitle: 'Linux $(python.version)' + - task: PublishCodeCoverageResults@1 + inputs: + codeCoverageTool: Cobertura + summaryFileLocation: '$(System.DefaultWorkingDirectory)/**/coverage.xml' + reportDirectory: '$(System.DefaultWorkingDirectory)/**/htmlcov' + condition: eq(variables['coverage'], true) + - script: | + bash <(curl https://codecov.io/bash) -t bbc2bdbe-5e67-4fef-9cb7-f52fe0b703a8 -f coverage.xml -F adder -F subtractor -F conda + displayName: 'codecov' + condition: eq(variables['coverage'], true) + + +- job: 'Test_conda_windows' + + pool: + vmImage: 'vs2017-win2016' + + strategy: + matrix: + Python35-windows: + python.version: '35' + Python36-windows: + python.version: '36' + Python37-windows: + python.version: '37' + + steps: + - powershell: Write-Host "##vso[task.prependpath]$env:CONDA\Scripts" + displayName: Add conda to PATH + - script: conda env create --quiet --file ci/requirements-py$(python.version).yml + displayName: Create Anaconda environment + - script: | + call activate test_env + pip install pytest-azurepipelines + pip install -e . + displayName: 'pip dependencies' + - script: | + call activate test_env + conda list + displayName: 'List installed dependencies' + - script: | + call activate test_env + set NREL_API_KEY=$(nrelApiKey) + echo %NREL_API_KEY% + pytest pvlib --junitxml=junit/test-results.xml + displayName: 'pytest' + - task: PublishTestResults@2 + inputs: + testResultsFiles: '**/test-results.xml' + testRunTitle: 'Windows $(python.version)' + + +- job: 'Test_bare_macOS_Mojave' + + pool: + vmImage: 'macOS-10.14' + strategy: + matrix: + Python35: + python.version: '3.5' + Python36: + python.version: '3.6' + Python37: + python.version: '3.7' + + steps: + - task: UsePythonVersion@0 + inputs: + versionSpec: '$(python.version)' + + - script: | + pip install pytest pytest-cov pytest-mock pytest-timeout pytest-azurepipelines + pip install -e . + export NREL_API_KEY=$(nrelApiKey) + echo $NREL_API_KEY + pytest pvlib --junitxml=junit/test-results.xml --cov=pvlib --cov-report=xml --cov-report=html + displayName: 'Test with pytest' + + - task: PublishTestResults@2 + condition: succeededOrFailed() + inputs: + testResultsFiles: '**/test-*.xml' + testRunTitle: 'Publish test results for Python $(python.version)' + + - task: PublishCodeCoverageResults@1 + inputs: + codeCoverageTool: Cobertura + summaryFileLocation: '$(System.DefaultWorkingDirectory)/**/coverage.xml' + reportDirectory: '$(System.DefaultWorkingDirectory)/**/htmlcov' + + +- job: 'Publish' + dependsOn: 'Test_conda_linux' + pool: + vmImage: 'ubuntu-latest' + + steps: + - task: UsePythonVersion@0 + inputs: + versionSpec: '3.x' + architecture: 'x64' + + - script: python setup.py sdist + displayName: 'Build sdist' From 3237f8ec822ed18b73767f5dbb915eef505cfa22 Mon Sep 17 00:00:00 2001 From: Cameron Stark Date: Tue, 4 Feb 2020 12:42:34 -0700 Subject: [PATCH 61/69] install pytest-rerunrailures in Azure --- azure-pipelines.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 2ecd50c52a..81df9204d1 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -26,7 +26,7 @@ jobs: versionSpec: '$(python.version)' - script: | - pip install pytest pytest-cov pytest-mock pytest-timeout pytest-azurepipelines + pip install pytest pytest-cov pytest-mock pytest-timeout pytest-azurepipelines pytest-rerunfailures pip install -e . export NREL_API_KEY=$(nrelApiKey) echo "This is the key: $NREL_API_KEY" @@ -160,7 +160,7 @@ jobs: versionSpec: '$(python.version)' - script: | - pip install pytest pytest-cov pytest-mock pytest-timeout pytest-azurepipelines + pip install pytest pytest-cov pytest-mock pytest-timeout pytest-azurepipelines pytest-rerunfailures pip install -e . export NREL_API_KEY=$(nrelApiKey) echo $NREL_API_KEY From 5c6835815254d4fdaf2664585ca434f8d771180c Mon Sep 17 00:00:00 2001 From: Cameron Stark Date: Wed, 5 Feb 2020 12:20:33 -0700 Subject: [PATCH 62/69] configure conda_35 tests to pull pytest_rerunfailures from pip instead of conda --- ci/requirements-py35.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/requirements-py35.yml b/ci/requirements-py35.yml index 2da7935ebb..db5403899e 100644 --- a/ci/requirements-py35.yml +++ b/ci/requirements-py35.yml @@ -17,7 +17,6 @@ dependencies: - pytest-cov - pytest-mock - pytest-timeout - - pytest-rerunfailures - python=3.5 - pytz - requests @@ -27,3 +26,4 @@ dependencies: - pip: - nrel-pysam - pvfactors==1.0.1 + - pytest-rerunfailures From b8d536ce55a9c913a6f0c4f50f6b0be6d93b2b5d Mon Sep 17 00:00:00 2001 From: Cameron Stark Date: Wed, 5 Feb 2020 12:48:56 -0700 Subject: [PATCH 63/69] add note for pytest-rerunfailures for conda_35 --- ci/requirements-py35.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/requirements-py35.yml b/ci/requirements-py35.yml index db5403899e..f589df2580 100644 --- a/ci/requirements-py35.yml +++ b/ci/requirements-py35.yml @@ -26,4 +26,4 @@ dependencies: - pip: - nrel-pysam - pvfactors==1.0.1 - - pytest-rerunfailures + - pytest-rerunfailures # conda version is >3.6 From 72e38804f5a8c6d60db7d2171ed2e6f566015d73 Mon Sep 17 00:00:00 2001 From: Cameron Stark Date: Wed, 5 Feb 2020 15:06:55 -0700 Subject: [PATCH 64/69] change fixture from DEMO_KEY to nrel_api_key --- pvlib/tests/iotools/test_psm3.py | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/pvlib/tests/iotools/test_psm3.py b/pvlib/tests/iotools/test_psm3.py index acf23f39f5..b25576e8e1 100644 --- a/pvlib/tests/iotools/test_psm3.py +++ b/pvlib/tests/iotools/test_psm3.py @@ -26,7 +26,7 @@ @pytest.fixture(scope="module") -def DEMO_KEY(): +def nrel_api_key(): """""" try: demo_key = os.environ["NREL_API_KEY"] @@ -66,34 +66,34 @@ def assert_psm3_equal(header, data, expected): @needs_pandas_0_22 @pytest.mark.flaky(reruns=5, reruns_delay=2) -def test_get_psm3_tmy(DEMO_KEY): +def test_get_psm3_tmy(nrel_api_key): """test get_psm3 with a TMY""" - header, data = psm3.get_psm3(LATITUDE, LONGITUDE, DEMO_KEY, PVLIB_EMAIL, - names='tmy-2017') + header, data = psm3.get_psm3(LATITUDE, LONGITUDE, nrel_api_key, + PVLIB_EMAIL, names='tmy-2017') expected = pd.read_csv(TMY_TEST_DATA) assert_psm3_equal(header, data, expected) @needs_pandas_0_22 @pytest.mark.flaky(reruns=5, reruns_delay=2) -def test_get_psm3_singleyear(DEMO_KEY): +def test_get_psm3_singleyear(nrel_api_key): """test get_psm3 with a single year""" - header, data = psm3.get_psm3(LATITUDE, LONGITUDE, DEMO_KEY, PVLIB_EMAIL, - names='2017', interval=30) + header, data = psm3.get_psm3(LATITUDE, LONGITUDE, nrel_api_key, + PVLIB_EMAIL, names='2017', interval=30) expected = pd.read_csv(YEAR_TEST_DATA) assert_psm3_equal(header, data, expected) @pytest.mark.parametrize('latitude, longitude, api_key, names, interval', [(LATITUDE, LONGITUDE, 'BAD', 'tmy-2017', 60), - (51, -5, DEMO_KEY, 'tmy-2017', 60), - (LATITUDE, LONGITUDE, DEMO_KEY, 'bad', 60), - (LATITUDE, LONGITUDE, DEMO_KEY, '2017', 15), + (51, -5, nrel_api_key, 'tmy-2017', 60), + (LATITUDE, LONGITUDE, nrel_api_key, 'bad', 60), + (LATITUDE, LONGITUDE, nrel_api_key, '2017', 15), ]) @needs_pandas_0_22 @pytest.mark.flaky(reruns=5, reruns_delay=2) def test_get_psm3_tmy_errors( - DEMO_KEY, latitude, longitude, api_key, names, interval + latitude, longitude, api_key, names, interval ): """Test get_psm3() for multiple error scenarios: * Bad api key -> HTTP 403 forbidden because api_key is rejected From 6cdc1865e4f6ab88d00f9e290329bb44a3d05973 Mon Sep 17 00:00:00 2001 From: Cameron Stark Date: Wed, 5 Feb 2020 15:16:35 -0700 Subject: [PATCH 65/69] remove debug variable echo commands --- azure-pipelines.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 81df9204d1..f008531824 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -29,7 +29,6 @@ jobs: pip install pytest pytest-cov pytest-mock pytest-timeout pytest-azurepipelines pytest-rerunfailures pip install -e . export NREL_API_KEY=$(nrelApiKey) - echo "This is the key: $NREL_API_KEY" pytest pvlib --junitxml=junit/test-results.xml --cov=com --cov-report=xml --cov-report=html displayName: 'Test with pytest' @@ -78,7 +77,6 @@ jobs: - script: | source activate test_env export NREL_API_KEY=$(nrelApiKey) - echo $NREL_API_KEY pytest pvlib --junitxml=junit/test-results.xml --cov --cov-report=xml --cov-report=html displayName: 'pytest' # - script: | @@ -132,7 +130,6 @@ jobs: - script: | call activate test_env set NREL_API_KEY=$(nrelApiKey) - echo %NREL_API_KEY% pytest pvlib --junitxml=junit/test-results.xml displayName: 'pytest' - task: PublishTestResults@2 @@ -163,7 +160,6 @@ jobs: pip install pytest pytest-cov pytest-mock pytest-timeout pytest-azurepipelines pytest-rerunfailures pip install -e . export NREL_API_KEY=$(nrelApiKey) - echo $NREL_API_KEY pytest pvlib --junitxml=junit/test-results.xml --cov=pvlib --cov-report=xml --cov-report=html displayName: 'Test with pytest' From be8eca014267da2491fc63f1bf57dc9f6098a057 Mon Sep 17 00:00:00 2001 From: Cameron Stark Date: Wed, 5 Feb 2020 16:06:47 -0700 Subject: [PATCH 66/69] move pytest-rerunfailures to pip install --- ci/requirements-py35-min.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/requirements-py35-min.yml b/ci/requirements-py35-min.yml index 0a1b16b1b7..c1d5283293 100644 --- a/ci/requirements-py35-min.yml +++ b/ci/requirements-py35-min.yml @@ -9,10 +9,10 @@ dependencies: - pytest-cov - pytest-mock - pytest-timeout - - pytest-rerunfailures - python=3.5 - pytz - requests - pip: - numpy==1.12.0 - pandas==0.18.1 + - pytest-rerunfailures # conda version is >3.6 From 33fe42e7131217a0fca1686104d400aff1cd4fc2 Mon Sep 17 00:00:00 2001 From: Cameron Stark Date: Wed, 5 Feb 2020 17:27:05 -0700 Subject: [PATCH 67/69] improve docstrings --- pvlib/tests/iotools/test_psm3.py | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/pvlib/tests/iotools/test_psm3.py b/pvlib/tests/iotools/test_psm3.py index b25576e8e1..e1024d565a 100644 --- a/pvlib/tests/iotools/test_psm3.py +++ b/pvlib/tests/iotools/test_psm3.py @@ -27,7 +27,13 @@ @pytest.fixture(scope="module") def nrel_api_key(): - """""" + """Supplies pvlib-python's NREL Developer Network API key. + + Azure Pipelines CI utilizes a secret variable set to NREL_API_KEY + to mitigate failures associated with using the default key of + "DEMO_KEY". A user is capable of using their own key this way if + desired however the default key should suffice for testing purposes. + """ try: demo_key = os.environ["NREL_API_KEY"] except KeyError: @@ -95,11 +101,13 @@ def test_get_psm3_singleyear(nrel_api_key): def test_get_psm3_tmy_errors( latitude, longitude, api_key, names, interval ): - """Test get_psm3() for multiple error scenarios: - * Bad api key -> HTTP 403 forbidden because api_key is rejected - * Bad latitude/longitude -> Coordinates were not found in the NSRDB - * Bad name -> names is not one of the available options - * Bad interval, single year -> intervals can only be 30 or 60 minutes + """Test get_psm3() for multiple erroneous input scenarios. + + These scenarios include: + * Bad API key -> HTTP 403 forbidden because api_key is rejected. + * Bad latitude/longitude -> Coordinates were not found in the NSRDB. + * Bad name -> Name is not one of the available options. + * Bad interval, single year -> Intervals can only be 30 or 60 minutes. """ with pytest.raises(HTTPError) as e: psm3.get_psm3(latitude, longitude, api_key, PVLIB_EMAIL, From 6d9230e5839167db3e032280fc9cb01cb953e266 Mon Sep 17 00:00:00 2001 From: Cameron Stark Date: Wed, 5 Feb 2020 17:53:59 -0700 Subject: [PATCH 68/69] use verbose name for caught error --- pvlib/tests/iotools/test_psm3.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pvlib/tests/iotools/test_psm3.py b/pvlib/tests/iotools/test_psm3.py index e1024d565a..1f20c549ee 100644 --- a/pvlib/tests/iotools/test_psm3.py +++ b/pvlib/tests/iotools/test_psm3.py @@ -104,16 +104,16 @@ def test_get_psm3_tmy_errors( """Test get_psm3() for multiple erroneous input scenarios. These scenarios include: - * Bad API key -> HTTP 403 forbidden because api_key is rejected. + * Bad API key -> HTTP 403 forbidden because api_key is rejected * Bad latitude/longitude -> Coordinates were not found in the NSRDB. * Bad name -> Name is not one of the available options. * Bad interval, single year -> Intervals can only be 30 or 60 minutes. """ - with pytest.raises(HTTPError) as e: + with pytest.raises(HTTPError) as excinfo: psm3.get_psm3(latitude, longitude, api_key, PVLIB_EMAIL, names=names, interval=interval) # ensure the HTTPError caught isn't due to overuse of the API key - assert "OVER_RATE_LIMIT" not in str(e.value) + assert "OVER_RATE_LIMIT" not in str(excinfo.value) @pytest.fixture From cdff1af7af5bd714189cdf626edd3ddb54f22744 Mon Sep 17 00:00:00 2001 From: Cameron Stark Date: Mon, 10 Feb 2020 09:34:27 -0700 Subject: [PATCH 69/69] readd leap year test --- pvlib/tests/iotools/test_psm3.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/pvlib/tests/iotools/test_psm3.py b/pvlib/tests/iotools/test_psm3.py index 1f20c549ee..7c8196645a 100644 --- a/pvlib/tests/iotools/test_psm3.py +++ b/pvlib/tests/iotools/test_psm3.py @@ -90,6 +90,15 @@ def test_get_psm3_singleyear(nrel_api_key): assert_psm3_equal(header, data, expected) +@needs_pandas_0_22 +@pytest.mark.flaky(reruns=5, reruns_delay=2) +def test_get_psm3_check_leap_day(nrel_api_key): + _, data_2012 = psm3.get_psm3(LATITUDE, LONGITUDE, nrel_api_key, + PVLIB_EMAIL, names="2012", interval=60, + leap_day=True) + assert len(data_2012) == (8760 + 24) + + @pytest.mark.parametrize('latitude, longitude, api_key, names, interval', [(LATITUDE, LONGITUDE, 'BAD', 'tmy-2017', 60), (51, -5, nrel_api_key, 'tmy-2017', 60),