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

Combine funtofem, pyfuntofem folder into funtofem #183

Merged
merged 12 commits into from
May 31, 2023

Conversation

sean-engelstad
Copy link
Contributor

@sean-engelstad sean-engelstad commented May 20, 2023

  • Simplify the funtofem package by moving all python and cython code from funtofem and pyfuntofem folders into the funtofem folder for consistency. This way the python module installed by anaconda is called funtofem which matches the conda package name and the github repo name.
  • Import TransferScheme and MELD classes for mphys with from funtofem import TransferScheme and from funtofem.mphys import MeldBuilder, etc.
  • Previous classes and interfaces which were imported with pyfuntofem such as from pyfuntofem.model import FUNtoFEMmodel or from pyfuntofem.driver import FUNtoFEMnlbgs are imported now with from funtofem.model import FUNtoFEMmodel and from funtofem.driver import FUNtoFEMnlbgs

@sean-engelstad sean-engelstad added the enhancement New feature or request label May 20, 2023
@sean-engelstad sean-engelstad linked an issue May 20, 2023 that may be closed by this pull request
@sean-engelstad sean-engelstad removed the enhancement New feature or request label May 20, 2023
@sean-engelstad
Copy link
Contributor Author

sean-engelstad commented May 20, 2023

This PR addresses the Issue, #140, in which the TransferScheme is stored in a separate folder and are not part of pyfuntofem package so they can't be imported directly from conda. I also moved mphys from funtofem folder into the pyfuntofem/interface/mphys folder now and they are automatically imported all the way up the top pyfuntofem level. I asked @A-CGray to review this since you use mphys.

@A-CGray
Copy link
Contributor

A-CGray commented May 20, 2023

So is the idea that my existing MPhys scripts run fine as-is with this import:

from funtofem.mphys import MeldBuilder

Or do I need to change something?

@sean-engelstad
Copy link
Contributor Author

You need to change it to from pyfuntofem import MeldBuilder now

@sean-engelstad
Copy link
Contributor Author

@A-CGray is that okay with you?

Copy link
Contributor

@bburke38 bburke38 left a comment

Choose a reason for hiding this comment

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

Just need @A-CGray to approve since this directly affects you.

@A-CGray
Copy link
Contributor

A-CGray commented May 25, 2023

I'm getting this error when running make interface:

pip install -e .
Obtaining file:///home/ali/repos/funtofem
  Installing build dependencies ... done
  Checking if build backend supports build_editable ... done
  Getting requirements to build editable ... error
  error: subprocess-exited-with-error
  
  × Getting requirements to build editable did not run successfully.
  │ exit code: 1
  ╰─> [19 lines of output]
      Traceback (most recent call last):
        File "/home/ali/.pyenv/versions/3.10.9/envs/Aviation2023/lib/python3.10/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 353, in <module>
          main()
        File "/home/ali/.pyenv/versions/3.10.9/envs/Aviation2023/lib/python3.10/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 335, in main
          json_out['return_val'] = hook(**hook_input['kwargs'])
        File "/home/ali/.pyenv/versions/3.10.9/envs/Aviation2023/lib/python3.10/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 132, in get_requires_for_build_editable
          return hook(config_settings)
        File "/tmp/pip-build-env-mwtpa9nn/overlay/lib/python3.10/site-packages/setuptools/build_meta.py", line 450, in get_requires_for_build_editable
          return self.get_requires_for_build_wheel(config_settings)
        File "/tmp/pip-build-env-mwtpa9nn/overlay/lib/python3.10/site-packages/setuptools/build_meta.py", line 341, in get_requires_for_build_wheel
          return self._get_build_requires(config_settings, requirements=['wheel'])
        File "/tmp/pip-build-env-mwtpa9nn/overlay/lib/python3.10/site-packages/setuptools/build_meta.py", line 323, in _get_build_requires
          self.run_setup()
        File "/tmp/pip-build-env-mwtpa9nn/overlay/lib/python3.10/site-packages/setuptools/build_meta.py", line 487, in run_setup
          super(_BuildMetaLegacyBackend,
        File "/tmp/pip-build-env-mwtpa9nn/overlay/lib/python3.10/site-packages/setuptools/build_meta.py", line 338, in run_setup
          exec(code, locals())
        File "<string>", line 6, in <module>
      ModuleNotFoundError: No module named 'numpy'
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
error: subprocess-exited-with-error

× Getting requirements to build editable did not run successfully.
│ exit code: 1
╰─> See above for output.

I definitely have numpy installed

@sean-engelstad sean-engelstad changed the title Move funtofem folder into pyfuntofem Move funtofem and mphys folder into pyfuntofem May 26, 2023
@sean-engelstad
Copy link
Contributor Author

sean-engelstad commented May 26, 2023

@A-CGray I recreated your error by starting a new conda environment in python 3.8 and python 3.10. Both versions gave me the same numpy error as you. Here's what I did to fix it, main thing was conda installing numpy. Can you try again?

conda create -n F2F python=3.8
conda activate F2F
conda install -c conda-forge numpy mpi4py cython
conda install gxx_linux-64=9.3.0 -q -y
cd ~/git/funtofem
make clean
make
make interface

@sean-engelstad
Copy link
Contributor Author

sean-engelstad commented May 28, 2023

@A-CGray I added the pyproject.toml to this pull request. I submitted a PR to mphys OpenMDAO/mphys#152, and waiting on word back from that.

@sean-engelstad sean-engelstad linked an issue May 28, 2023 that may be closed by this pull request
@timryanb
Copy link
Collaborator

@sean-engelstad can we preserve the mphys subpackage in the import path i.e. from pyfuntofem.mphys import MeldBuilder. This keeps consistent with the other tools in the mphys library.

Also it sounds like this will be a breaking change, which means it should follow with a version bump

@timryanb
Copy link
Collaborator

It's probably worth mentioning this on the mphys call so the other users are aware of this as well

@sean-engelstad
Copy link
Contributor Author

sean-engelstad commented May 29, 2023

@timryanb I just moved the mphys folder from pyfuntofem.interface.mphys to pyfuntofem.mphys like you requested. The import will be from pyfuntofem.mphys import MeldBuilder, etc. I also updated the mphys PR for the imports there.

pyproject.toml Outdated
#pyproject.toml
[build-system]
# Minimum requirements for the build system to execute.
requires = ['setuptools>=45.0', 'wheel', 'cython>=0.29', 'oldest-supported-numpy', 'mpi4py==3.1.1']
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you make this 'mpi4py>=3.1.1'? I have 3.1.4 and it tried to install 3.1.1 unnecessarily

Copy link
Collaborator

@timryanb timryanb May 29, 2023

Choose a reason for hiding this comment

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

pip will still likely install a temporary version of mpi4py during the build regardless @kejacobson. This is how pip handles building cython packages. In general we pin against older versions of mpi4py because they are always forward compatible if the users system mpi4py is newer. I'd recommend keeping the mpi4py version number as was, since we've seen issues in the past with pip trying to build codes against newer versions mpi4py than the user is running. This is the same reason we specify 'numpy-oldest' in the build section

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok I changed this back to mpi4py==3.1.1 then. I thought there was a reason that was the convention in TACS

Copy link
Contributor

Choose a reason for hiding this comment

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

Interesting, it didn't seem forward compatible when I tried to build it. My pip failed when building mpi4py 3.1.1 with ==, but found my existing 3.1.4 with the >= change.

Copy link
Collaborator

@timryanb timryanb May 29, 2023

Choose a reason for hiding this comment

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

Weird. Do you have the failure message? Also what version of pip are you using?

@sean-engelstad
Copy link
Contributor Author

@kejacobson I've changed the pyproject.toml file to mpi4py>=3.1.1 now.

@timryanb
Copy link
Collaborator

@timryanb I just moved the mphys folder from pyfuntofem.interface.mphys to pyfuntofem.mphys like you requested. The import will be from pyfuntofem.mphys import MeldBuilder, etc. I also updated the mphys PR for the imports there.

You can also accomplish this by adding from interface import mphys to pyfuntofem/__init__.py if you still want to house the mphys directory under interfaces

@sean-engelstad
Copy link
Contributor Author

I decided to leave the mphys folder in the directory pyfuntofem/mphys since I was having trouble getting that to work @timryanb. It allowed me to do from pyfuntofem import mphys but not from pyfuntofem.mphys import MeldBuilder since there was no mphys submodule in that directory. Importing it into there didn't seem to work. I also tried setting up a mphys.py submodule file, but that doens't work you need another mphys folder in that place.

@sean-engelstad sean-engelstad changed the title Move funtofem and mphys folder into pyfuntofem Combine funtofem,pyfuntofem,mphys folder into funtofem May 30, 2023
@sean-engelstad sean-engelstad changed the title Combine funtofem,pyfuntofem,mphys folder into funtofem Combine funtofem, pyfuntofem, mphys folder into funtofem May 30, 2023
@sean-engelstad
Copy link
Contributor Author

Brian and I have decided to instead combine all the python and cython code into the funtofem folder not the pyfuntofem folder. This way the conda package funtofem installs the python module funtofem which is consistent with the conda package and repo name (otherwise with pyfuntofem it is confusing and mismatching). This is a non-backwards compatible change so we will be releasing a new version after this.

pyproject.toml Outdated Show resolved Hide resolved
@sean-engelstad sean-engelstad changed the title Combine funtofem, pyfuntofem, mphys folder into funtofem Combine funtofem, pyfuntofemfolder into funtofem May 30, 2023
@sean-engelstad sean-engelstad changed the title Combine funtofem, pyfuntofemfolder into funtofem Combine funtofem, pyfuntofem folder into funtofem May 30, 2023
@bburke38 bburke38 self-requested a review May 30, 2023 23:55
Copy link
Contributor

@bburke38 bburke38 left a comment

Choose a reason for hiding this comment

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

@sean-engelstad Can you change the first topic in the conversation to indicate the new import name?

@sean-engelstad
Copy link
Contributor Author

@bburke38 I updated the main message block of the PR to say that we are merging into funtofem now and how the imports have changed.

@bburke38 bburke38 self-requested a review May 31, 2023 15:36
@sean-engelstad sean-engelstad merged commit e256b5f into smdogroup:master May 31, 2023
6 checks passed
@sean-engelstad sean-engelstad deleted the pyfuntofem_only branch August 23, 2023 19:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Can't find numpy package build error Transfer schemes are not part of pyFUNtoFEM package
5 participants