-
Notifications
You must be signed in to change notification settings - Fork 768
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
Sometimes the referenced objects and methods may appear as Unknown #4684
Comments
This isn't the kind of issue that we can figure out from a log. Please file a new issue when you are able to provide code the reproduces what you are seeing. |
Okay, I will try to provide a small code that can be shared publicly, and then file a new issue. |
This issue is not reproducible 100%. I would like to ask what possible factors need to be taken into consideration to narrow down the scope |
Well, I don't have a lot of context so it's tough to speculate, but here are some ideas:
|
Thank you for your suggestion. |
I've tried to provide a reduced-scope project code, but I can't reliably reproduce the issue. It still occurs probabilistically. I've updated the issue description. |
Could you reopen this issue? I have to go to the hospital now and might not have time to filea new issue. |
After updating the github copilot extension and reloading the window, I also encounter this issue. |
Hello, can the information currently provided help identify the problem? |
Sorry for the delayed response. I was on vacation last week. I was just able to reproduce the issue! Only once so far, but that's promising. I wasn't seeing it when just starting VS Code. But you mentioned that it repro'd after reloading the window due to updating an extension. The same thing happened when I downgraded Pylance from 2023.8.20 to 2023.8.10 and reloaded the window. I'll continue investigating. |
No problem, hope you had a great vacation! I'm glad you were able to reproduce this issue. It has indeed caused some inconvenience to my current work. |
Repro steps:
|
@erictraut, could you take a look at this? I think it's a type evaluation issue. A race condition of some sort? It repros in both Pylance (2023.8.10+, and possibly earlier) and Pyright (1.1.322 and tip of main -- microsoft/pyright@393be11). See repro steps in my previous comment. The type shown when hovering over There are a couple other symbols, all base class-related, that are also curiously
I can repro it fairly easily -- maybe 10-20% of the time -- but have never managed to repro it in the debugger. I was able to simplify import openai
import langchain
import faiss
from langchain.cache import SQLiteCache
from langchain.chat_models import ChatOpenAI
from langchain.embeddings import OpenAIEmbeddings
from langchain.vectorstores import FAISS
from langchain.docstore import InMemoryDocstore
from langchain.retrievers import TimeWeightedVectorStoreRetriever
from pydantic import BaseModel
from agency.agent import Agent, access_policy, ACCESS_PERMITTED
from agency.amqp_space import AMQPSpace
from pp import GenerativeAgent, GenerativeAgentMemory
langchain.llm_cache = SQLiteCache(database_path=".langchain.db")
llm = ChatOpenAI(client=openai.Completion)
embeddings_model = OpenAIEmbeddings(client=openai.Embedding)
class BrainAgent(Agent):
def __init__(self, id: str):
super().__init__(id)
self.brain = "str"
def _action__todo(self, objective: str) -> None:
res = self.brain |
This isn't a race condition, since we don't have any asynchronous code within the type evaluator. However, it does smell like a case where different evaluation order produces different results. A hover request is a high priority, so if it gets queued before the lower-priority full type check of the file, it will cause the types of some nodes to be evaluated. I've done my best to repro the problem, but I'm not able to. I even tried increasing the If you're able to repro it semi-consistently, let's take advantage of that and try to diagnose the problem on your machine. Here's the process I recommend. First, set |
I wasn't able to repro the issue that way. But I also remembered that when reproing this I've been waiting for the variable |
That's correct. The diagnostic hint is generated as part of the checking process, so if you see the grayed-out text appear, then |
To be clear, I'm saying that the issue repros when I hover after that diagnostic hint appears. Any other theories as to what might be going on here? |
No, but if you can repro it on a semi-deterministic basis, you could set a conditional breakpoint and step through the code when it hits. For example, if the problem appears to be with evaluating |
Sadly I still can't repro this in the debugger, but I was able to make some progress by adding extra logging and reproing the issue on a custom When the bug repros, the I haven't dug into where that |
OK, that's a good clue. It sounds like there's some circular dependency in the code being analyzed. That can lead to type evaluation behaviors that differ based on where in the cycle the evaluation begins. At the point where |
Stack is below. Turns out that And strangely, when the bug repros, the type returned by
|
@erictraut, I finally figured it out. An There are two sets of Should the class be removed from the type cache in this case?
|
Ah, good find. That explains why I wasn't able to repro this in pyright. I have cancellations disabled in the debug build because they make debugging very difficult. Removing the type from the type cache would eliminate this problem some of the time, but it's not sufficient to completely fix the problem. Circular references can result in legitimate cases where there are references to a partially-constructed class. For example, one of the base classes of class The safest thing to do is to completely discard the entire type evaluator instance (i.e. call A variant of that idea is to say that cancellation exceptions that happen within certain pieces of code, such as Any other ideas? |
Ok, that sounds good. I'll give that a shot. |
This issue has been fixed in prerelease version 2023.8.41, which we've just released. You can find the changelog here: CHANGELOG.md |
Thank you |
Environment data
Code Snippet
PP.zip
Repro Steps
Expected behavior
It should complete indexing normally and display the corresponding type.
Actual behavior
Didn't see 'index done' in the log, and the type is 'Unknown'.
Logs
trace_log.txt
The text was updated successfully, but these errors were encountered: