UKGovernmentBEIS / inspect_ai

Inspect: A framework for large language model evaluations
https://UKGovernmentBEIS.github.io/inspect_ai/
MIT License
400 stars 41 forks source link

Trying to `inspect view` fails with "No such file or directory" even though /logs is there #8

Closed navkuun closed 1 month ago

navkuun commented 1 month ago

I was trying to run the first security guide example and the evaluation runs fine and the /logs file shows up and the contents of the file are as it should be.

Here's the code from the example that I used

from inspect_ai import Task, eval, task
from inspect_ai.dataset import example_dataset
from inspect_ai.scorer import model_graded_fact
from inspect_ai.solver import generate, system_message

SYSTEM_MESSAGE = """
You are a computer security expert and you are tasked with
providing concise response to the following questions.
Please assume that the reader is also well versed in
computer security and provide a short response in a few words.
"""

@task
def security_guide():
    return Task(
        dataset=example_dataset("security_guide"),
        plan=[system_message(SYSTEM_MESSAGE), generate()],
        scorer=model_graded_fact(),
    )

However when I try to

inspect view

I get the following error

(llm-notebooks) PS C:\Users\Nk\Documents\notebooks\inspect\examples> inspect view
Inspect view running at http://localhost:7575/
[05/12/24 22:47:20] ERROR    [Errno 2] No such file or directory:                                                                                                               view.py:194
                             'C:/Users/N%K/Documents/notebooks/inspect/examples/logs/2024-05-12T22-46-40_security-guide_BsA6tV8Y7iR6vJ2zFVqSGD.json'
                             Traceback (most recent call last):
                               File "C:\Users\Nk\anaconda3\envs\llm-notebooks\Lib\site-packages\inspect_ai\_view\view.py", line 182, in handle_log
                                 with file(path, "rb") as f:
                               File "C:\Users\Nk\anaconda3\envs\llm-notebooks\Lib\contextlib.py", line 137, in __enter__
                                 return next(self.gen)
                                        ^^^^^^^^^^^^^^
                               File "C:\Users\Nk\anaconda3\envs\llm-notebooks\Lib\site-packages\inspect_ai\_util\file.py", line 81, in file
                                 with open_file as f:
                               File "C:\Users\Nk\anaconda3\envs\llm-notebooks\Lib\site-packages\fsspec\core.py", line 103, in __enter__
                                 f = self.fs.open(self.path, mode=mode)
                                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                               File "C:\Users\Nk\anaconda3\envs\llm-notebooks\Lib\site-packages\fsspec\spec.py", line 1293, in open
                                 f = self._open(
                                     ^^^^^^^^^^^
                               File "C:\Users\Nk\anaconda3\envs\llm-notebooks\Lib\site-packages\fsspec\implementations\local.py", line 197, in _open
                                 return LocalFileOpener(path, mode, fs=self, **kwargs)
                                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                               File "C:\Users\Nk\anaconda3\envs\llm-notebooks\Lib\site-packages\fsspec\implementations\local.py", line 322, in __init__
                                 self._open()
                               File "C:\Users\Nk\anaconda3\envs\llm-notebooks\Lib\site-packages\fsspec\implementations\local.py", line 327, in _open
                                 self.f = open(self.path, mode=self.mode)
                                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                             FileNotFoundError: [Errno 2] No such file or directory:
                             'C:/Users/N%k/Documents/notebooks/inspect/examples/logs/2024-05-12T22-46-40_security-guide_BsA6tV8Y7iR6vJ2zFVqSGD.json'

It says it's a file not found error but the file is clearly there image

Using Python 3.12.2. The VScode extension also shows up when I run 'inspect view' in the CLI but it shows up as a blank new tab.

Would appreciate some help with this.

sdtblckgov commented 1 month ago

Hi @navkuun !

Thanks for the issue report. My guess is the error here is due to inspect view trying to read C:/Users/N%k/Documents/... whereas your logs seem to be located at C:/Users/Nk/Documents/.... (notice the stray % symbol).

Afaict the view command can see your logs, or you would be hitting this exit point here.

But it looks like when you actually make a get request and it comes into handle_log, the path has become malformed somehow on the way to the logs being read. It's possible that some of the parsing steps here could have inadvertently caused this, but more details would be useful for us to narrow it down.

  1. What is the correct User path? is it C:/Users/Nk/, C:/Users/N%k/, or C:/Users/N%K/? (all three of which seem to be present in the logs, which is perplexing.). Sharing the true full path would be helpful so we can debug this on our end.
  2. If you pass in the log_dir manually to inspect, do you observe the same behaviour?
  3. Are there any extended ASCII characters in the true path? (https://www.lookuptables.com/text/extended-ascii-table)
  4. If you add a breakpoint or print statement to the top of handle_logs, what is the value of self.path at the entrance to the function?