-
Notifications
You must be signed in to change notification settings - Fork 242
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
I am getting "NameError: name 'overall_cls' is not defined" error when I run python raw2read.py #80
Comments
Hi, thanks for your info. I rerun the code but do not encounter the same error, you may diff your "raw2read.py" with the one in our repo to see if there are any changes, or you may try to upgrade your "concurrent" packages? |
I git cloned the repo and used VS code. Python Version is 3.11. Here is the troubleshooting I did> I am trying to run a python code and I am getting this error: Traceback (most recent call last): Here's the relevant part of the traceback: csharp To resolve this issue: Check the spelling: Ensure that you've spelled the variable/function name correctly everywhere it's used. Will you be kind enough to look into the folder that has the above code and tell me what is going wrong and suggest me steps to fix the issue? comparison.png Finished working python truncate the context to meet the max_seq_lencontext_wo_title = overall_cls.truncate_sentence(context_wo_title, max_len=overall_cls.max_seq_len-200) To fully diagnose the issue, I need to check if overall_cls is defined elsewhere in the file or if it's supposed to be passed as an argument to the search function or accessed in some other way. Let's continue analyzing the file to understand how overall_cls is intended to be used. Finished working python To fix the issue, you have a few options: Pass overall_cls as an Argument: Modify the search function definition to accept overall_cls as an argument and pass it when calling the function. Give me modified code to paste or save Modify the search function definition: Finished working Replace your original file with this modified version, and the NameError should be resolved. max_workers: 12 The above exception was the direct cause of the following exception: Traceback (most recent call last): To address this, you can define a new function that wraps around the search function with the required arguments, rather than using a lambda function. Here's what we can do: Define a new function called search_wrapper that takes just the entry argument and calls search(entry, overall_cls) inside. Finished working Replace your original file with this updated version, and it should resolve the pickling issue related to the lambda function. max_workers: 12 The above exception was the direct cause of the following exception: Traceback (most recent call last): To resolve this, we need to pass overall_cls as part of the data being mapped over. One way to do this is to modify the data passed to process_map to include both the entry and overall_cls for each item. Here's the plan: Instead of passing raw_texts directly to process_map, we'll pass a list of tuples, where each tuple contains an entry and overall_cls. Finished working Replace your original file with this latest version, and it should address the issue with the overall_cls not being accessible in the worker processes. File "C:\Users\rajas\Desktop\LMOps-main\adaptllm\raw2read_modified_v3.py", line 98 Let's correct this and provide you with the updated file. Finished working Replace your original file with this latest version, and it should resolve the indentation error. File "C:\Users\rajas\Desktop\LMOps-main\adaptllm\raw2read_modified_v4.py", line 100 I will correct the indentation for the line for entry in read_compre: and any subsequent lines that may be affected. Finished working Replace your original file with this version, and it should address the IndentationError. you cant do it. same error To ensure I address the problem correctly, I will explicitly look at the section of code around the line causing the error, adjust the indentation, and share that portion with you for confirmation before creating the entire file. Finished working Here's the corrected section: python print('saving reading comprehension texts...') sort by text_id to align with the order of raw textsfor entry in read_compre: print(f'saved to {args.output_dir}') Finished working Replace your original file with this latest version, and it should resolve the IndentationError. I am trying to do like shown in this page: The repository you've shared is Microsoft's Language Model Operations (LMOps) framework for adapting and deploying large language models. The errors you're facing arise from the raw2read.py script, which converts raw text to a reading comprehension format. From the details you've provided and the code fixes we've worked on, here's a recommended approach: Dependencies: Make sure all the dependencies are correctly installed. Navigate to the adaptllm folder and run: Run the Script: Once you've replaced the file, try running the script again: bash Check Other Scripts: If you intend to run other scripts from the LMOps repository, it might be a good idea to check them for potential issues as well. Given that you encountered errors with raw2read.py, there might be other scripts that require updates or fixes. Python Version: Ensure you're using a compatible Python version. Some code might behave differently across Python versions. The repository doesn't explicitly mention a version, but since your error logs showed Python 3.11, it might be worth trying with a more commonly used version like Python 3.8 or 3.9, in case there are compatibility issues. GitHub Issues: If you continue to face challenges, consider checking the "Issues" section of the GitHub repository. Others might have encountered similar problems, and solutions or workarounds could be discussed there. If not, you can create a new issue detailing the problems you're facing. Following these steps should help you progress with the LMOps framework. If you encounter further issues, please let me know, and I'll assist you. Thanks in advance |
Thanks for your reply, but I have some difficulties in understanding your info (it seems like a generated response from ChatGPT). Could you please specify your info? |
I also get the same error.
I am trying to execute the code with the given examples. |
@shamanez |
@rajvadiyala @shamanez We have fixed this problem by adding functools in process_map |
Nice yeah .. I guess the problem was with the func tools
…On Thu, 26 Oct 2023 at 6:33 PM, Shaohan Huang ***@***.***> wrote:
@rajvadiyala <https://github.com/rajvadiyala> @shamanez
<https://github.com/shamanez> We have fixed this problem by adding
functools in process_map
—
Reply to this email directly, view it on GitHub
<#80 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AEA4FGUNIG2OCHVXDVUN273YBHY27AVCNFSM6AAAAAA5NSTUM6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTOOBQGQ2DGMZRGE>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Hello all, when I run python raw2read.py I am getting "NameError: name 'overall_cls' error. Here I am providing part log.
Help me in fixing in this issue.
PS C:\Users\rajas\Desktop\AI_Research\LMOps-main\LMOps-main\adaptllm> python raw2read.py
max_workers: 12
loading raw texts in the input folder...
paths: ['./data_samples/input-raw-texts\0.txt', './data_samples/input-raw-texts\1.txt', './data_samples/input-raw-texts\10.txt', './data_samples/input-raw-texts\11.txt', './data_samples/input-raw-texts\2.txt', './data_samples/input-raw-texts\3.txt', './data_samples/input-raw-texts\4.txt', './data_samples/input-raw-texts\5.txt', './data_samples/input-raw-texts\6.txt', './data_samples/input-raw-texts\7.txt', './data_samples/input-raw-texts\8.txt', './data_samples/input-raw-texts\9.txt']
12it [00:00, ?it/s]
transferring raw texts into reading comprehension...
0%| | 0/12 [00:00<?, ?it/s]
concurrent.futures.process._RemoteTraceback:
"""
Traceback (most recent call last):
File "C:\Users\rajas\AppData\Local\Programs\Python\Python311\Lib\concurrent\futures\process.py", line 256, in _process_worker
r = call_item.fn(*call_item.args, **call_item.kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\rajas\AppData\Local\Programs\Python\Python311\Lib\concurrent\futures\process.py", line 205, in _process_chunk
return [fn(*args) for args in chunk]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\rajas\AppData\Local\Programs\Python\Python311\Lib\concurrent\futures\process.py", line 205, in
return [fn(*args) for args in chunk]
^^^^^^^^^
File "C:\Users\rajas\Desktop\AI_Research\LMOps-main\LMOps-main\adaptllm\raw2read.py", line 19, in search
context_wo_title = overall_cls.truncate_sentence(context_wo_title, max_len=overall_cls.max_seq_len-200)
^^^^^^^^^^^
NameError: name 'overall_cls' is not defined
Thanks in advance
The text was updated successfully, but these errors were encountered: