Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature 2669 proj comp #2710

Merged
merged 11 commits into from
Oct 10, 2023
Merged

Feature 2669 proj comp #2710

merged 11 commits into from
Oct 10, 2023

Conversation

jprestop
Copy link
Collaborator

@jprestop jprestop commented Oct 6, 2023

Expected Differences

  • Do these changes introduce new tools, command line arguments, or configuration file options? [No]

    If yes, please describe:

  • Do these changes modify the structure of existing or add new output data types (e.g. statistic line types or NetCDF variables)? [No]

    If yes, please describe:

Pull Request Testing

  • Describe testing already performed for these changes:

    Installed on Jet and Hera.

  • Recommend testing for the reviewer(s) to perform, including the location of input datasets, and any additional instructions:

    Ensure all tests pass and review code changes.

  • Do these changes include sufficient documentation updates, ensuring that no errors or warnings exist in the build of the documentation? [Yes for now, the documentation is undergoing modifications]

  • Do these changes include sufficient testing updates? [N/A]

  • Will this PR result in changes to the test suite? [No]

    If yes, describe the new output and/or changes to the existing output:

  • Please complete this pull request review by [At your convenience before working on modifications to the compilation script for Enhance MET to compile and link against the Atlas and ecKit libraries #2574].

Pull Request Checklist

See the METplus Workflow for details.

  • Review the source issue metadata (required labels, projects, and milestone).
  • Complete the PR definition above.
  • Ensure the PR title matches the feature or bugfix branch name.
  • Define the PR metadata, as permissions allow.
    Select: Reviewer(s) and Development issue
    Select: Milestone as the version that will include these changes
    Select: Coordinated METplus-X.Y Support project for bugfix releases or MET-X.Y.Z Development project for official releases
  • After submitting the PR, select the ⚙️ icon in the Development section of the right hand sidebar. Search for the issue that this PR will close and select it, if it is not already selected.
  • After the PR is approved, merge your changes. If permissions do not allow this, request that the reviewer do the merge.
  • Close the linked issue and delete your feature or bugfix branch from GitHub.

@jprestop jprestop added this to the MET 12.0.0 milestone Oct 6, 2023
Copy link
Collaborator

@JohnHalleyGotway JohnHalleyGotway left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately, I think we need to work some more on this.

The dtcenter/METbaseimage repo uses this compile_MET_all.sh script to create the docker testing environment for MET and METplus. So I tried rebuilding that environment by:

  1. Cloning METbaseimage:
git clone https://github.com/dtcenter/METbaseimage
cd METbaseimage
  1. Updating Dockerfile to pull from your feature branch.
cat Dockerfile | sed 's%/develop/%/feature_2669_proj_comp/%g' > Dockerfile.new
mv Dockerfile.new Dockerfile
  1. Building the image:
docker build -t met-base:feature_2669_proj_comp .

This errors out with on the compilation of PROJ:

Using python version: 
./compile_MET_all.sh: line 397: /usr/local/bin/python3: No such file or directory
...
-- Could NOT find Python (missing: Python_EXECUTABLE Interpreter) 
-- PROJ: Configured 'dist' target
-- Configuring incomplete, errors occurred!

Here's an issue...
I believe that python is required to compile sqlite or proj. But in the Dockerfile, we intentionally run compile_MET_all.sh FIRST and compile python SECOND so that we can compile python using the NetCDF library that was compiled by compile_MET_all.sh. So that's a circular dependency.

Currently, the Dockerfile does already install sqlite3 as a package, and it's available in /usr/include/sqlite3.h and /usr/lib/x86_64-linux-gnu/libsqlite3.so. So we could stick with that without relying on compile_MET_all.sh to compile it.

BUT even that is not working.

  • SQLITE_DIR is NOT currently set in the development.docker environment file in the MET repo.
  • If we wanted to set it, we couldn't because it is used as:
-DSQLITE3_INCLUDE_DIR=${SQLITE_DIR}/include
-DSQLITE3_LIBRARY=${SQLITE_DIR}/lib/libsqlite3.so

But that won't actually resolve to the right locations in the Docker environment.
We'd need to use /usr/lib/x86_64-linux-gnu/libsqlite3.so instead of /usr/lib/libsqlite3.so.

  • If we leave it unset, then line compile_MET_all.sh:160 sets it to LIB_DIR:
SQLITE_DIR=${LIB_DIR}
  • But then compile_MET_all.sh:403 checks if its set:
if [[ -z "$SQLITE_DIR" ]]; then

But of course its set... its always set... by line 160. And because of that, I don't think compile_MET_all.sh would ever actually compile sqlite.

I just don't think this logic is doing what you want it to do. So let's take a look at this together next week and decide how we want the logic to work in METbaseimage, along with HPC's (hera, jet, and so on).

Co-authored-by: John Halley Gotway <johnhg@ucar.edu>
@jprestop
Copy link
Collaborator Author

jprestop commented Oct 9, 2023

@JohnHalleyGotway Thank you for remembering to test this for the docker testing environment for MET and METplus and for finding these problems! I'm thinking that the circular dependency won't be a problem for most, if any, and that using the sqlite3 that is already installed as a package is probably a good way to go considering the circumstances. If you agree, what do you think about changing SQLITE_DIR to SQLITE_INCLUDE_DIR and SQLITE_LIB_DIR and changing the configure options for proj to the following?

-DSQLITE3_INCLUDE_DIR=${SQLITE_INLCUDE_DIR}
-DSQLITE3_LIBRARY=${SQLITE_LIB_DIR}/libsqlite3.so

and modifying the following as well:

if [[ -z "$SQLITE_DIR" ]]; then

to check for the setting of the two new variables?

@JohnHalleyGotway
Copy link
Collaborator

@jprestop as we discussed on 10/9/23, this sounds like a good approach. Remember to update line 160 to set a COMPILE_SQLITE variable to true or false based on whether or not the user has already specified the location of sqlite to use.

@jprestop
Copy link
Collaborator Author

jprestop commented Oct 9, 2023

@JohnHalleyGotway I made the changes we discussed to compile_MET_all.sh. I tested on Jet by setting both SQLITE_INCLUDE_DIR and SQLITE_LIB_DIR and testing on Hera by not setting either. Thank you for including these directions for testing with METbaseimage:

git clone https://github.com/dtcenter/METbaseimage
cd METbaseimage
cat Dockerfile | sed 's%/develop/%/feature_2669_proj_comp/%g' > Dockerfile.new
mv Dockerfile.new Dockerfile
docker build -t met-base:feature_2669_proj_comp .

which allowed me to retest with these changes. Unfortunately, I received a seemingly unrelated error with the installation of numpy (see below for details). Looking up the error:

 ../../numpy/meson.build:207:4: ERROR: Problem encountered: No BLAS library detected! Install one, or use the `allow-noblas` build option (note, this may be up to 100x slower for some linear algebra operations).

I came across this page, which indicated that numpy v1.26 is very new (3 weeks and 2 days ago (16 Sep 2023)) so no wheels are available. The same user says that once available, this problem should solve itself. So, in the METbaseimage Dockerfile, I added a specific version for numpy: python3 -m pip install ${BLDOPTS} numpy==1.25.2 to see if I could get a successful compilation. However, I'm not sure this is the best solution. The test compilation is still running. I'll update here again once I know if it was successful or not.

Details of numpy error:

377.7 Collecting numpy
377.8   Downloading numpy-1.26.0.tar.gz (15.6 MB)
378.3      ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 15.6/15.6 MB 30.6 MB/s eta 0:00:00
380.8   Installing build dependencies: started
513.0   Installing build dependencies: still running...
583.4   Installing build dependencies: still running...
645.8   Installing build dependencies: still running...
653.5   Installing build dependencies: finished with status 'done'
653.5   Getting requirements to build wheel: started
653.6   Getting requirements to build wheel: finished with status 'done'
653.6   Installing backend dependencies: started
742.5   Installing backend dependencies: still running...
759.1   Installing backend dependencies: finished with status 'done'
759.1   Preparing metadata (pyproject.toml): started
768.1   Preparing metadata (pyproject.toml): finished with status 'error'
768.1   error: subprocess-exited-with-error
768.1   
768.1   × Preparing metadata (pyproject.toml) did not run successfully.
768.1   │ exit code: 1
768.1   ╰─> [57 lines of output]
768.1       + /usr/local/bin/python3 /tmp/pip-install-dcoklisk/numpy_04cf8f00b6b745db9bb96cf15320d0d2/vendored-meson/meson/meson.py setup /tmp/pip-install-dcoklisk/numpy_04cf8f00b6b745db9bb96cf15320d0d2 /tmp/pip-install-dcoklisk/numpy_04cf8f00b6b745db9bb96cf15320d0d2/.mesonpy-z2eezcnz/build -Dbuildtype=release -Db_ndebug=if-release -Db_vscrt=md --native-file=/tmp/pip-install-dcoklisk/numpy_04cf8f00b6b745db9bb96cf15320d0d2/.mesonpy-z2eezcnz/build/meson-python-native-file.ini
768.1       The Meson build system
768.1       Version: 1.2.99
768.1       Source dir: /tmp/pip-install-dcoklisk/numpy_04cf8f00b6b745db9bb96cf15320d0d2
768.1       Build dir: /tmp/pip-install-dcoklisk/numpy_04cf8f00b6b745db9bb96cf15320d0d2/.mesonpy-z2eezcnz/build
768.1       Build type: native build
768.1       Project name: NumPy
768.1       Project version: 1.26.0
768.1       C compiler for the host machine: /usr/bin/gcc (gcc 12.2.0 "gcc (Debian 12.2.0-14) 12.2.0")
768.1       C linker for the host machine: /usr/bin/gcc ld.bfd 2.40
768.1       C++ compiler for the host machine: /usr/bin/g++ (gcc 12.2.0 "g++ (Debian 12.2.0-14) 12.2.0")
768.1       C++ linker for the host machine: /usr/bin/g++ ld.bfd 2.40
768.1       Cython compiler for the host machine: cython (cython 3.0.3)
768.1       Host machine cpu family: x86_64
768.1       Host machine cpu: x86_64
768.1       Program python found: YES (/usr/local/bin/python3)
768.1       Found pkg-config: /usr/bin/pkg-config (1.8.1)
768.1       Run-time dependency python found: YES 3.10
768.1       Has header "Python.h" with dependency python-3.10: YES
768.1       Compiler for C supports arguments -fno-strict-aliasing: YES
768.1       Test features "SSE SSE2 SSE3" : Supported
768.1       Test features "SSSE3" : Supported
768.1       Test features "SSE41" : Supported
768.1       Test features "POPCNT" : Supported
768.1       Test features "SSE42" : Supported
768.1       Test features "AVX" : Supported
768.1       Test features "F16C" : Supported
768.1       Test features "FMA3" : Supported
768.1       Test features "AVX2" : Supported
768.1       Test features "AVX512F" : Supported
768.1       Test features "AVX512CD" : Supported
768.1       Test features "AVX512_KNL" : Supported
768.1       Test features "AVX512_KNM" : Supported
768.1       Test features "AVX512_SKX" : Supported
768.1       Test features "AVX512_CLX" : Supported
768.1       Test features "AVX512_CNL" : Supported
768.1       Test features "AVX512_ICL" : Supported
768.1       Test features "AVX512_SPR" : Supported
768.1       Configuring npy_cpu_dispatch_config.h using configuration
768.1       Message:
768.1       CPU Optimization Options
768.1         baseline:
768.1           Requested : min
768.1           Enabled   : SSE SSE2 SSE3
768.1         dispatch:
768.1           Requested : max -xop -fma4
768.1           Enabled   : SSSE3 SSE41 POPCNT SSE42 AVX F16C FMA3 AVX2 AVX512F AVX512CD AVX512_KNL AVX512_KNM AVX512_SKX AVX512_CLX AVX512_CNL AVX512_ICL AVX512_SPR
768.1       
768.1       Library m found: YES
768.1       Found CMake: /usr/bin/cmake (3.25.1)
768.1       WARNING: CMake Toolchain: Failed to determine CMake compilers state
768.1       Run-time dependency openblas found: NO (tried pkgconfig and cmake)
768.1       Run-time dependency openblas found: NO (tried pkgconfig and cmake)
768.1       
768.1       ../../numpy/meson.build:207:4: ERROR: Problem encountered: No BLAS library detected! Install one, or use the `allow-noblas` build option (note, this may be up to 100x slower for some linear algebra operations).
768.1       
768.1       A full log can be found at /tmp/pip-install-dcoklisk/numpy_04cf8f00b6b745db9bb96cf15320d0d2/.mesonpy-z2eezcnz/build/meson-logs/meson-log.txt
768.1       [end of output]
768.1   
768.1   note: This error originates from a subprocess, and is likely not a problem with pip.
768.1 error: metadata-generation-failed

@jprestop
Copy link
Collaborator Author

jprestop commented Oct 9, 2023

The run was unsuccessful at first, due to xarray attempting to reinstall numpy version 1.26.0 after already having installed numpy version 1.25.2. I remembered a comment in this Discussion's answer, which said:

If you get an error for the xarray step - remove the --force-reinstall flag in the BLDOPTS variable

So, I modified the Dockerfile to remove ${BLDOPTS} from this line python3 -m pip install ${BLDOPTS} xarray and also needed to remove ${BLDOPTS} from python3 -m pip install ${BLDOPTS} netCDF4 as well (as it also tried to reinstall numpy version 1.26.0), which finally resulted in a successful compilation.

@JohnHalleyGotway Do these changes need to be made in METbaseimage, or since we have a successful METbaseimage-3.0 release, do we not need to worry about these issues now?

Copy link
Collaborator

@JohnHalleyGotway JohnHalleyGotway left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I approve of these changes, but did suggest a minor change to comments in the script.

I'll note that we discussed in Slack that we expect the version-itis issues you uncovered testing in METbaseimage to resolve themselves in the next weeks/months as the python package versions become available in wheel. So we don't need to make any changes in METbaseimage now.

I reviewed the changes and note that you did add entries for SQLITE_INCLUDE_DIR and SQLITE_LIB_DIR to development.docker. Thanks for testing that out.

I did NOT test this script on seneca, namely because we don't actually use it there.

jprestop and others added 2 commits October 10, 2023 11:15
Co-authored-by: John Halley Gotway <johnhg@ucar.edu>
Co-authored-by: John Halley Gotway <johnhg@ucar.edu>
@jprestop
Copy link
Collaborator Author

I just wanted to add a note that the failure in the Check for Differences is unrelated. I am going to proceed with the squash and merge.

@jprestop jprestop merged commit bb90592 into develop Oct 10, 2023
33 of 34 checks passed
@jprestop jprestop linked an issue Oct 18, 2023 that may be closed by this pull request
21 tasks
@jprestop jprestop deleted the feature_2669_proj_comp branch August 26, 2024 19:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: 🏁 Done
Development

Successfully merging this pull request may close these issues.

Enhance MET to compile and link against the Proj library
2 participants