Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
JamesMakela-NOAA committed Jun 5, 2024
2 parents d082c24 + 5a104cf commit abb4503
Show file tree
Hide file tree
Showing 211 changed files with 1,572 additions and 728 deletions.
83 changes: 83 additions & 0 deletions .github/workflows/conda_test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
name: Run tests with miniconda
on: [push]

jobs:
test:
name: Miniconda ${{ matrix.os }} Py${{ matrix.pyver }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
#os: ["ubuntu-latest", "windows-latest","macos-latest"]
os: ["windows-latest","macos-latest"]
pyver: ["3.9", "3.10", "3.11"]
steps:
- uses: actions/checkout@v4
- uses: conda-incubator/setup-miniconda@v3
with:
activate-environment: test
# environment-file: environment.yml
python-version: ${{ matrix.pyver }}
auto-activate-base: false
- shell: bash -l {0}
run: |
conda config --add channels conda-forge
- name: Setup environment
shell: bash -l {0}
run: |
git clone --depth 1 -b develop https://github.com/NOAA-ORR-ERD/adios_oil_database.git oil_database
conda install -y mamba
cd ./py_gnome
echo "Setting up conda environment"
mamba install -y python=${{ matrix.pyver }} \
--file conda_requirements.txt \
--file conda_requirements_build.txt \
--file conda_requirements_test.txt \
--file ../oil_database/adios_db/conda_requirements.txt
- name: Build Our Packages
shell: bash -l {0}
run: |
pwd
ls -la
pip install ./oil_database/adios_db/
cd ./py_gnome
python -m pip install ./
- name: Run pytest
shell: bash -l {0}
run: |
cd ./py_gnome/tests/unit_tests
pytest --runslow
- name: Build wheel file
shell: bash -l {0}
run: |
cd ./py_gnome
python -m pip wheel ./
- name: Copy files to artifact folder
shell: bash -l {0}
run: |
mkdir installable_wheel_${{ matrix.os }}_Py${{ matrix.pyver }}
cp ./py_gnome/*.whl installable_wheel_${{ matrix.os }}_Py${{ matrix.pyver }}
cp ./py_gnome/conda_requirements.txt installable_wheel_${{ matrix.os }}_Py${{ matrix.pyver }}
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: installable-wheel-${{ matrix.os }}-Py${{ matrix.pyver }}
path: installable_wheel_${{ matrix.os }}_Py${{ matrix.pyver }}

lint:
name: Flake8 linting
runs-on: "ubuntu-latest"
steps:
- uses: actions/checkout@v4
- uses: conda-incubator/setup-miniconda@v3
with:
activate-environment: lint
python-version: 3.9
auto-activate-base: false
- shell: bash -l {0}
run: |
conda config --add channels conda-forge
- name: Lint
shell: bash -l {0}
run: |
conda install flake8
python -m flake8 --exit-zero --statistics py_gnome/gnome/
113 changes: 71 additions & 42 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ variables:

stages:
- compile
- test
- build
- test

cache:
paths:
Expand Down Expand Up @@ -44,22 +44,27 @@ compile_pygnome:

# get the adios_db code: needed for tests and requirements
- git clone --depth 1 -b develop https://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.orr.noaa.gov/gnome/oil_database/oil_database.git
- cd ./py_gnome
- conda install -y python=$PYTHON_VER --file conda_requirements.txt
--file conda_requirements_build.txt
--file oil_database/adios_db/conda_requirements.txt
--file ../oil_database/adios_db/conda_requirements.txt

# install adios_db
- pip install oil_database/adios_db/

- cd ./py_gnome
- python setup.py install

- cd ../ # make sure that it won't find the source gnome package.
- python -c "import gnome" # make sure that it imports
- pip install ../oil_database/adios_db/

# Install pygnome
# If you want verbose output including the compiler/linker commands,
# run the following command:
# python -m build --no-isolation --config-setting cmake.verbose=true
#
# And there may be times we want to build a wheel file (.whl)
# The following command will build a wheel in the current directory:
# python -m pip wheel ./
- python -m pip install ./

# need extra requirements for the docs
- conda install -y --file conda_requirements_docs.txt
- cd py_gnome/documentation && make html # build the docs
- cd documentation && make html # build the docs
artifacts:
when: always
expire_in: 15 days
Expand All @@ -76,8 +81,10 @@ test_pygnome:
allow_failure: false
image: registry.orr.noaa.gov/erd/centos-conda/$IMAGE_NAME$PYTHON_VER
script:
- conda install -y --file conda_requirements_test.txt
- conda install -y --file py_gnome/conda_requirements_test.txt
- cd ./py_gnome/tests/unit_tests && pytest --runslow

# save the package list if tests pass
- conda list > conda_packages.txt

# Ideally, all the scripts in "testing_scripts" should run without errors,
Expand Down Expand Up @@ -109,56 +116,78 @@ test_pygnome_windows:
- windows
- visual-studio-22
allow_failure: true
cache: []
before_script:
- echo $CI_PIPELINE_ID

# where are we?
- Get-Location
- dir
- Get-ChildItem | % { $_.FullName } # this should list the current folder
- $Env:PathOrig = $Env:Path
- $Env:CurrDir = Get-Location

# Where is our conda installation?
# This will tell us where python is installed. This could change periodically
#- Get-ChildItem -Path 'C:\Python310' -Recurse -Include "python.exe", "conda.exe" | % { $_.FullName }
#- Get-ChildItem -Path 'C:\ProgramData\miniforge3' -Recurse -Include "python.exe", "conda.exe" | % { $_.FullName }

# make sure conda is on the path first in the path
- $Env:Path = 'C:\ProgramData\Miniconda3\Library\bin;' + $Env:Path
- $Env:Path = 'C:\ProgramData\Miniconda3\;' + $Env:Path
- $Env:Path = 'C:\ProgramData\Miniconda3\Scripts;' + $Env:Path
- $Env:Path = 'C:\ProgramData\miniforge3\;' +
'C:\ProgramData\miniforge3\Scripts;' +
'C:\ProgramData\miniforge3\Lib\bin;' +
$Env:PathOrig
- $Env:Path -split ';'

- echo "Our environemt vars:"
- $Env:Path
- python -c "import sys; print(sys.executable)"

# This might be changing our current directory. It only needs to be run
# one time anyway, so we will comment it out.
#- Invoke-Expression "conda shell.powershell hook"
#- conda init powershell

# On SO, it was suggested that this would perform a `conda init`
# without needing to restart PowerShell. So we will test it.
- C:\ProgramData\miniforge3\shell\condabin\conda-hook.ps1

- echo $CI_PIPELINE_ID
- conda activate ./$CI_PIPELINE_ID
- conda config --add channels defaults
- conda config --add channels conda-forge
- conda config --get channels
- conda config --set channel_priority strict
script:
- echo "Building and testing PyGNOME"

# # make sure our conda package is first in the path
# - $Env:Path = 'C:\ProgramData\Miniconda3\Library\bin;' + $Env:Path
# - $Env:Path = 'C:\ProgramData\Miniconda3\;' + $Env:Path
# - $Env:Path = 'C:\ProgramData\Miniconda3\Scripts;' + $Env:Path

- echo "Our environemt vars:"
- $Env:Path
- conda create -y -p ./pygnome python=$PYTHON_VER

- echo "Python is running from:"
- python -c "import sys; print(sys.executable)"
#- $Env:Path = '' +
# (Get-Location) + '\pygnome\;' +
# (Get-Location) + '\pygnome\Scripts\;' +
# (Get-Location) + '\pygnome\Lib\bin\;' +
# $Env:PathOrig
- conda activate ./pygnome
script:
- echo "Building and testing PyGNOME"

# get the adios_db code: needed for tests and requirements
- git clone --depth 1 -b develop https://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.orr.noaa.gov/gnome/oil_database/oil_database.git

- conda install -y python=$PYTHON_VER mamba
- cd ./py_gnome
- echo "Setting up conda environment"
- mamba install -y python=$PYTHON_VER --file conda_requirements.txt
--file conda_requirements_build.txt
--file conda_requirements_test.txt
--file oil_database/adios_db/conda_requirements.txt
--file ../oil_database/adios_db/conda_requirements.txt

- echo "Building PyGNOME"
- cd ./py_gnome
# - python setup.py install
- python setup.py develop

# Make sure that it imports from some folder other than the
# gnome package folder.
# - cd ../
# - python -c "import gnome"
# install adios_db
- pip install ../oil_database/adios_db/

# Install pygnome
# If you want verbose output including the compiler/linker commands,
# run the following command:
# python -m build --no-isolation --config-setting cmake.verbose=true
#
# And there may be times we want to build a wheel file (.whl)
# The following command will build a wheel in the current directory:
# python -m pip wheel ./
- python -m pip install ./

- cd ./tests/unit_tests
- pytest --runslow
Expand All @@ -180,9 +209,9 @@ build_develop:

# build the py_gnome image
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
- docker build . --build-arg PYTHON_VER=$PYTHON_VER -t registry.orr.noaa.gov/gnome/pygnome:develop
- docker build . --build-arg PYTHON_VER=$PYTHON_VER -t registry.orr.noaa.gov/gnome/pygnome:$CI_COMMIT_BRANCH
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
- docker push registry.orr.noaa.gov/gnome/pygnome:develop
- docker push registry.orr.noaa.gov/gnome/pygnome:$CI_COMMIT_BRANCH

build_main:
stage: build
Expand Down
24 changes: 6 additions & 18 deletions Install_without_conda.rst
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Building everything by hand / with pip

It is always good practice to create and run a complex system like this in a virtual environment of some sort: virtualenv, pipenv, etc.

A virtual environment is **not required** to run PyGNOME.
A virtual environment is *not required* to run PyGNOME.
But you may be working in an environment (on a corporate network, for example) that restricts your access to the system files on your computer.
In such a case, you may require a virtualenv in order to freely install python packages in python's site-packages dir. (site-packages is the standard place where python installers will put packages after building them)

Expand Down Expand Up @@ -121,18 +121,14 @@ Download and install the newest Windows executable distribution of

`Python 3.10 <http://www.python.org/download/>`_

(3.9 -- 3.11 shoule work)
(3.9 -- 3.12 should work)

A number of the packages that GNOME depends on have very complex and
brittle build processes, and depend on third-party libraries that can be
a challenge to build.

Fortunately, many of them are available as binary wheels on PyPi

Another option is to use a Python scientific distribution, such as
`Anaconda <https://www.anaconda.com/products/distribution>`_ -- in which case, stop and read the ``Installing.rst`` file.


Dependencies can be installed using the command::

> pip install -r requirements.txt
Expand All @@ -152,25 +148,17 @@ Build PyGNOME
> cd PyGNOME/py_gnome
> pip install -r requirements.txt

3. Install the adios_db pacakge -- it is under active development along with py_gnome, so it's best to install that from source as well:
3. Install the adios_db package -- it is under active development along with py_gnome, so it's best to install that from source as well:

https://github.com/NOAA-ORR-ERD/adios_oil_database/tree/production/adios_db

4. build the ``py_gnome`` module in develop or install mode:
4. build the ``py_gnome`` module in editable or install mode.

``> python setup.py build``
``> python -m pip install ./``

or

``> python setup.py install``

or

``> python setup.py develop``

The other option you may need is ``cleanall``, which should clean the development environment -- good to do after puling new code from git::

> python setup.py cleanall
``> python -m pip install --editable ./``


5. If this successfully completes, then run the unit tests::
Expand Down
Loading

0 comments on commit abb4503

Please sign in to comment.