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

fme missing attribute 'get_device' on clean install #22

Open
ngordillo opened this issue Nov 7, 2024 · 5 comments
Open

fme missing attribute 'get_device' on clean install #22

ngordillo opened this issue Nov 7, 2024 · 5 comments

Comments

@ngordillo
Copy link

Doing a clean install of ACE and creating the environment, the fme module is missing elements needed to run. I've tested this out on two different machines get the same error message.

Traceback (most recent call last):
  File "/home/nicojg/mambaforge/envs/fme/lib/python3.10/runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/home/nicojg/mambaforge/envs/fme/lib/python3.10/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/home/nicojg/ace/fme/fme/ace/inference/__main__.py", line 8, in <module>
    main(yaml_config=args.yaml_config)
  File "/home/nicojg/ace/fme/fme/ace/inference/inference.py", line 221, in main
    run_inference_from_config(config)
  File "/home/nicojg/ace/fme/fme/ace/inference/inference.py", line 235, in run_inference_from_config
    logging.info(f"Current device is {fme.get_device()}")
AttributeError: module 'fme' has no attribute 'get_device'

I managed to work around this by uninstalling fme after running make create_environment and then reinstalling to the latest version.

@oliverwm1
Copy link
Collaborator

Thanks for reporting. I am not able to reproduce this so far.

Do you also have the issue if installing directly from PyPI?

@oliverwm1
Copy link
Collaborator

I was able to reproduce this. It happens specifically when in the root directory of this repo (e.g. call python -c "import fme; fme.get_device()" from root dir of the repo). But does not happen when running the command elsewhere.

@ngordillo
Copy link
Author

I did a clean install of ACE on a system that didn't have mamba installed and it worked following the quick start guide on the first attempt. So I am inclined to believe that this is an issue with mamba.

@frodre
Copy link
Contributor

frodre commented Jan 10, 2025

Turns out this is related to our usage of a development install -e and there being an fme folder in the top level that's not the actual package source folder fme/fme. Python path includes the local directory by default in sys.path and searches there first, so it finds the top-level fme assumes it's the package but then finds no submodules.

Python 3.10.16 (main, Dec 11 2024, 16:24:50) [GCC 11.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import fme
>>> fme.get_device()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: module 'fme' has no attribute 'get_device'
>>> 

If I remove the current working directory from sys.path, the error goes away.

Python 3.10.16 (main, Dec 11 2024, 16:24:50) [GCC 11.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.path
['', '/home/andrep/miniconda3/envs/fme/lib/python310.zip', '/home/andrep/miniconda3/envs/fme/lib/python3.10', '/home/andrep/miniconda3/envs/fme/lib/python3.10/lib-dynload', '/home/andrep/miniconda3/envs/fme/lib/python3.10/site-packages', '__editable__.fme-2024.12.0.finder.__path_hook__']
>>> del sys.path[0]
>>> import fme
>>> fme.get_device()
device(type='cpu')
>>> 

We'll just have to update the folder naming convention so this won't bite others looking to do local dev work in this repo.

@oliverwm1
Copy link
Collaborator

@elynnwu found a nice workaround for now. Add -I to the python invocation, and things should work.

i.e. in the root dir of the repo, python -c "import fme; fme.get_device()" fails but python -I -c "import fme; fme.get_device()" works.

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

No branches or pull requests

3 participants