lettucecfd / lettuce

Computational Fluid Dynamics based on PyTorch and the Lattice Boltzmann Method
MIT License
222 stars 39 forks source link

[Bug]: numerous cases of deprecated Python syntax #219

Open tomviolin opened 3 months ago

tomviolin commented 3 months ago

Contact Details

tomh@uwm.edu

What happened?

When I install lettuce, either from source using git clone from the github repository, or from PyPi using pip install lettuce, I get the following error upon running the lettuce command from the shell:

  File "/home/tomh/lettuce/venv/lib/python3.10/site-packages/lettuce/__init__.py", line 61
    except Exception, e:
           ^^^^^^^^^^^^
SyntaxError: multiple exception types must be parenthesized

This appears to be an old deprecated except syntax from Python 2.x. When I go in and fix that one on my copy, it reveals a large number of similar errors that follow, along with several instances of the old Python 2.x print syntax.

How can this be, with a package that appears to have been completely authored after Python 2.x was EOLed?

Version

0.2.1, 0.2.3

What operating system are you seeing the problem on?

Linux

Relevant log output

$ lettuce
Traceback (most recent call last):
  File "/home/tomh/lettuce/venv/bin/lettuce", line 33, in <module>
    sys.exit(load_entry_point('lettuce==0.2.1', 'console_scripts', 'lettuce')())
  File "/home/tomh/lettuce/venv/bin/lettuce", line 25, in importlib_load_entry_point
    return next(matches).load()
  File "/usr/lib/python3.10/importlib/metadata/__init__.py", line 171, in load
    module = import_module(match.group('module'))
  File "/usr/lib/python3.10/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 992, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 879, in exec_module
  File "<frozen importlib._bootstrap_external>", line 1017, in get_code
  File "<frozen importlib._bootstrap_external>", line 947, in source_to_code
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/home/tomh/lettuce/venv/lib/python3.10/site-packages/lettuce/__init__.py", line 61
    except Exception, e:
           ^^^^^^^^^^^^
SyntaxError: multiple exception types must be parenthesized

Note that I see the same error whether I install lettuce 0.2.1 or 0.2.3. I haven't tried 0.2.2 because it seems the relevant code didn't change from 0.2.1 to 0.2.3.

PhiSpel commented 3 months ago

Hello @tomviolin

  1. Thank you for your feed back and sorry for the inconvenience!
  2. Which version of Python 3.10 are you using? So far, this error has not occured for us with 3.10 or 3.11, but an update may have introduced the deprecation. The first versions of lettuce were developed around the time when it was, to some, still more feasible or intuitive to use 2.x syntax. This should have of course by now been update.
  3. We are currently working on a new release with significant changes to the syntax. If you can wait only a few days, we'll have merged #200 so that you can see how to use the new version.
  4. If you cannot wait, please share your environment setup (conda list) so that we may be able to reproduce your error on Monday.
tomviolin commented 3 months ago

I'll wait for the update. Thanks!

PhiSpel commented 3 months ago

@tomviolin I tried again to reproduce your error on Linux using different orders of installation. However, I was unable to reach the same messages you received when running lettuce after python setup.py install or python setup.py develop. Could you share some further context about

  1. The steps you followed for the installation
  2. The list of packages you are using (ideally in a conda environment as this is how we all use it)
  3. The content of lettuce/__init__.py (which appears to be significantly different from what I see after I installed lettuce)

Also, try updating your environment before installing lettuce (conda update --all).

tomviolin commented 3 months ago

I will revisit my installation and get you the info.

In the meantime, can you please give me the exact steps you did to install lettuce without getting the errors? Maybe I'm doing something completely wrong.

-Tom

-- Tom Hansen, Ph.D. Programmer/Analyst-Research UWM School of Freshwater Sciences @.***


From: PhiSpel @.> Sent: Thursday, August 22, 2024 5:15 AM To: lettucecfd/lettuce @.> Cc: Thomas Frederick Hansen @.>; Mention @.> Subject: Re: [lettucecfd/lettuce] [Bug]: numerous cases of deprecated Python syntax (Issue #219)

@tomviolinhttps://github.com/tomviolin I tried again to reproduce your error on Linux using different orders of installation. However, I was unable to reach the same messages you received when running lettuce after python setup.py install or python setup.py develop. Could you share some further context about

  1. The conda environment you are using
  2. The content of lettuce/init.py (which appears to be significantly different from what I see after I installed lettuce)

— Reply to this email directly, view it on GitHubhttps://github.com/lettucecfd/lettuce/issues/219#issuecomment-2304294337, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ABHUVK7TP4JVMPCIES2UL7TZSW23FAVCNFSM6AAAAABMVE6WOOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGMBUGI4TIMZTG4. You are receiving this because you were mentioned.Message ID: @.***>

PhiSpel commented 3 months ago

I pretty much follow the instructions in README.rst (because these work well for Linux with conda and a GPU compatible with CUDA 12.1:

conda create -n lettuce
conda activate lettuce
conda install pytorch pytorch-cuda=12.1 -c pytorch -c nvidia
conda install -c pytorch -c conda-forge matplotlib pytest click pyevtk mmh3 h5py scipy pandas numpy
git clone https://github.com/lettucecfd/lettuce
cd lettuce
python setup.py install
lettuce convergence