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

logical_file.data_format_specs() throwing AttributeError 'dlisio.core.lis_stream' object has no attribute 'read_records' #401

Closed
AchyuthB opened this issue Nov 23, 2021 · 8 comments

Comments

@AchyuthB
Copy link

AchyuthB commented Nov 23, 2021

Hi,

I upgraded the dlisio from version 0.3.4 to 0.3.5. Now I get error while calling "logical_file.data_format_specs()".
It says
AttributeError("'dlisio.core.lis_stream' object has no attribute 'read_records'")

image

It was working fine with version 0.3.4.

Any help is highly appreciated.

Thanks
Achyuth

@ErlendHaa
Copy link
Contributor

I'm unable to reproduce this. Can you provide a minimal code example + a full stack trace

@AchyuthB
Copy link
Author

AchyuthB commented Nov 24, 2021

Hi @ErlendHaa,
Thank you for your reply. Below is the code snippet. The code formatting is not working here, hence I am pasting it without formatting.

The exception is throwing at this line for format_specs in logical_file.data_format_specs():

from dlisio import lis

def read_lis_file( input_file_path ):
    try:
        try:
            physical_file = lis.load(input_file_path)
        except Exception as e:
            return


        for logical_file in physical_file:
            for format_specs in logical_file.data_format_specs():
                pass

    except Exception as e:
        print(" - Script Warn: While processing logical file - " + str(e))
    finally:
        physical_file.close()


if __name__ == "__main__":
    g_input_file = 'D:\FeedFiles\LIS\A\/164_07-_1_dwl_DWL_WIRE_1648905.lis'
    try:
        read_lis_file(g_input_file)
    except Exception as e:
        print(str(e))
    exit(0)

@ErlendHaa
Copy link
Contributor

Hi,

I still can't reproduce. I'm unsure why it can't find read_records on lis_stream, it's clearly there [1]

.def( "read_records", &lis::iodevice::read_records )

Do you install dlisio trough pip? If so, have you tried installing a fresh instance in an isolated env?

@AchyuthB
Copy link
Author

Hi,

Yes i installed dlisio using pip, actually i upgraded it with the below command.
pip install dlisio==0.3.5
image

May be the error is due to something specific in my environment.
How do I test it isolated?
Also, any other suggestions or recommendations which could get this resolved?

Should I try by uninstalling and re-installing the latest dlisio?

Thank you so much for your patience.

Regards,
Achyuth

@ErlendHaa
Copy link
Contributor

I would think so, yes. Try re-installing, maybe in a virtual env. I'm also curious about the -lisio warnings you get. lisio was an old working name for the lis-parser, but it never got introduced upstream. Did you checkout some old version of a dlisio fork or something?

@AchyuthB
Copy link
Author

Hi @ErlendHaa,

I created a virtual environment and it worked as expected. Below are the steps i followed. Now have to figure out what is wrong with my environment.. :-(

I did not checkout any old version nor fork.

C:\>python -m venv D:\VirtualPython
D:\VirtualPython>D:\VirtualPython\Scripts\activate
(VirtualPython) D:\VirtualPython>py -m pip install dlisio

image

@AchyuthB
Copy link
Author

Hi,

It is working now.

1. I uninstalled all the packages

pip freeze > requirements.txt
pip uninstall -r requirements.txt

2. Deleted these folders
image

3. Then re-installed dlisio
pip install dlisio

@ErlendHaa
Copy link
Contributor

Great!

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

2 participants