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

pyhon > 3.6 compatibility fix #7

Closed
wants to merge 3 commits into from

Conversation

fraricci
Copy link

@fraricci fraricci commented May 1, 2019

  • run function replace popen
  • the logic to write the STDOUT to file hs been changed accordingly
  • iteritems() replaced with items()

I tested the three mode kpts, unfold and plot and they seems working fine with python > 3.6.

An error is raised if py 3.5 is used, though

hope this is helpful

- run function replace popen
- the logic to write the STDOUT to file hs been changed accordingly
- iteritems() replaced with items()
Copy link

@mbagheri20 mbagheri20 left a comment

Choose a reason for hiding this comment

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

HI,
the kpt producing worked properly but when I tried the ploting step the following Error appeared:

Traceback (most recent call last):
  File "/home/user/bandup-master/src/python_interface/bandupy/files.py", line 298, in create_bandup_input
    if(os.path.exists(dest)): raise OSError
OSError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/user/bandup-master/bandup", line 73, in <module>
    run_requested_task(args)
  File "/home/user/bandup-master/src/python_interface/bandupy/runners.py", line 61, in run_requested_task
    create_bandup_input(args)
  File "/home/user/bandup-master/src/python_interface/bandupy/files.py", line 320, in create_bandup_input
    'overwrite it.')
  File "/home/user/intel/intelpython3/lib/python3.7/warnings.py", line 110, in _showwarnmsg
    msg.file, msg.line)
TypeError: _new_showwarning() takes from 1 to 4 positional arguments but 6 were given

@fraricci
Copy link
Author

which command are you using? simple plot or using the gui?
I tried to do a plot and save it successfully.

@mbagheri20
Copy link

I used run_BandUP_unfold_and_plot_tasks.sh file from Si example

@fraricci
Copy link
Author

ok I see.
in the file /home/user/bandup-master/src/python_interface/bandupy/warning_wrapper.py
replace:
def _new_showwarning(message, category = UserWarning, filename = '', lineno = -1):
with
def _new_showwarning(message, category = UserWarning, filename = '', lineno = -1, msg_file=None, line=None):

@stepan-tsirkin
Copy link
Member

Dear @fraricci , thank you for this fix, and sorry for not replying for almost 2 years,
I checked, and it really works on python 3.8, but fails on python 3.6 .

If it is not hard to you, can you add a bit of backward compatibility, by modifying the changes in runners.py as :

if sys.version > '3.7' : 
    your_new_code
else :
    the_old_code

I understand that python3.6 is already old, but also some users may have reasons for not upgrading to newer versions.

Regards,
Stepan

@fraricci
Copy link
Author

let me check, I remember it was working in py3.6. It might be that the fix in the warning_wrapper doesn't.
Anyway, yes I can add the backward compatibility you mentioned.

@stepan-tsirkin
Copy link
Member

with Python 3.6.12 I get the following error

> ./run_BandUP_unfold_and_plot_tasks.sh
Traceback (most recent call last):
  File "/disk/data11/tfp/stepan/bandup/bandup", line 73, in <module>
    run_requested_task(args)
  File "/disk/data11/tfp/stepan/bandup/src/python_interface/bandupy/runners.py", line 62, in run_requested_task
    run_bandup(args)
  File "/disk/data11/tfp/stepan/bandup/src/python_interface/bandupy/runners.py", line 37, in run_bandup
    text=True)
  File "/usr/lib64/python3.6/subprocess.py", line 423, in run
    with Popen(*popenargs, **kwargs) as process:
TypeError: __init__() got an unexpected keyword argument 'capture_output'

can it be different is subversions of python3.6 ?

@nhew1994
Copy link

nhew1994 commented Apr 7, 2021

Hi Stepan, similar to python 3.6.12, using python 3.6.3 results in the same error as you stated above. I made a change to the "runners.py" file (see attached) and it seems to work in conjunction with the corrected files.py and warnings_wrapper.py file posted here.
runners.txt

@stepan-tsirkin
Copy link
Member

dear @nhew1994 ,
could you implement your suggestion as a pull request. For that you may clone the branch of @fraricci to your fork, implement the changes, and make a separate PR. Thus both commits of @fraricci and yours will be credited properly.

also , @fraricci , did you find time to implement a single version that works bothe in python 3.6 and 3.8 ? or @nhew1994 , can you do it?

@fraricci
Copy link
Author

fraricci commented Apr 9, 2021

Hello there, sorry for been unresponsive. I quickly tested the implementation by @nhew1994 that use Popen instead of run and it seems working both in 3.6 and 3.8 versions.
Also the warnings.showwarning wrapper seems working in both versions.

Could you @stepan-tsirkin double check?

@nhew1994 nhew1994 mentioned this pull request Apr 12, 2021
@stepan-tsirkin
Copy link
Member

This PR is substituted with #21 , which is now merged

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.

4 participants