Skip to content

Commit

Permalink
release v0.3.6
Browse files Browse the repository at this point in the history
  • Loading branch information
aisi-inspect committed May 6, 2024
1 parent eca65fc commit 2a0b6b9
Show file tree
Hide file tree
Showing 5 changed files with 70 additions and 37 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## v0.3.6 (06 May 2024)

- Show first log file immediately (don't wait for fetching metadata for other logs)
- Add `--version` CLI arg and `inspect info version` command for interogating version and runtime source path.
- Fix: exclude `null` config values in output from `inspect info log-file`

## v0.3.5 (04 May 2024)

- Fix issue with logs from S3 buckets in inspect view.
Expand Down
25 changes: 22 additions & 3 deletions src/inspect_ai/_cli/info.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
from json import dumps

import click

from inspect_ai import __version__
from inspect_ai._util.constants import PKG_PATH
from inspect_ai.log import read_eval_log
from inspect_ai.log import eval_log_json, read_eval_log


@click.group("info")
Expand All @@ -10,6 +13,22 @@ def info_command() -> None:
return None


@info_command.command("version")
@click.option(
"--json",
type=bool,
is_flag=True,
default=False,
help="Output version and path info as JSON",
)
def version(json: bool) -> None:
if json:
print(dumps(dict(version=__version__, path=PKG_PATH.as_posix()), indent=2))
else:
print(f"version: {__version__}")
print(f"path: {PKG_PATH.as_posix()}")


@info_command.command("log-file")
@click.argument("path")
@click.option(
Expand All @@ -22,7 +41,7 @@ def info_command() -> None:
def log(path: str, header_only: bool) -> None:
"""Print log file contents."""
log = read_eval_log(path, header_only=header_only)
print(log.model_dump_json(indent=2))
print(eval_log_json(log))


@info_command.command("log-schema")
Expand All @@ -38,6 +57,6 @@ def log_types() -> None:


def view_resource(file: str) -> str:
resource = PKG_PATH / "src" / "inspect_ai" / "_view" / "www" / file
resource = PKG_PATH / "_view" / "www" / file
with open(resource, "r", encoding="utf-8") as f:
return f.read()
21 changes: 15 additions & 6 deletions src/inspect_ai/_cli/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

from inspect_ai._util.dotenv import init_dotenv

from .. import __version__
from .eval import eval_command
from .info import info_command
from .list import list_command
Expand All @@ -10,17 +11,25 @@


@click.group(invoke_without_command=True)
@click.option(
"--version",
type=bool,
is_flag=True,
default=False,
help="Print the Inspect version.",
)
@click.pass_context
def inspect(
ctx: click.Context,
) -> None:
def inspect(ctx: click.Context, version: bool) -> None:
# if this was a subcommand then allow it to execute
if ctx.invoked_subcommand is not None:
return

# if invoked as plain 'inspect' just print help and exit
click.echo(ctx.get_help())
ctx.exit()
if version:
print(__version__)
ctx.exit()
else:
click.echo(ctx.get_help())
ctx.exit()


inspect.add_command(eval_command)
Expand Down
2 changes: 1 addition & 1 deletion src/inspect_ai/_util/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
PKG_AUTHOR = "UK AI Safety Institute"
PKG_AUTHOR_DIR = "UK-AISI"
PKG_NAME = Path(__file__).parent.parent.stem
PKG_PATH = Path(__file__).parent.parent.parent.parent
PKG_PATH = Path(__file__).parent.parent
DEFAULT_EPOCHS = 1
DEFAULT_MAX_RETRIES = 5
DEFAULT_TIMEOUT = 120
Expand Down
53 changes: 26 additions & 27 deletions src/inspect_ai/_view/www/App.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,29 @@ export function App() {
useEffect(() => {
// Default select the first item
let index = 0;

setSelected(index);
}, [logs]);

useEffect(() => {
useEffect(async () => {
// Read header information for the logs
// and then update
const headerResults = await Promise.all(logs.files.map((file) => {
return eval_log(file.name, true).then((result) => {
return { file: file.name, result };
}).catch(() => { return undefined});
}));

// Update the headers
const updatedHeaders = logHeaders;
for (const headerResult of headerResults) {
if (headerResult) {
updatedHeaders[headerResult.file] = headerResult.result;
}
}
setLogHeaders({ ...updatedHeaders });
}, [logs]);

useEffect(async () => {
const urlParams = new URLSearchParams(window.location.search);

// Note whether we should default off canvas the sidebar
Expand All @@ -35,40 +53,21 @@ export function App() {
// If the URL provides a task file, load that
const logPath = urlParams.get("task_file");
const loadLogs = logPath
? () => {
? async () => {
setLogs({
log_dir: "",
files: [{ name: logPath }],
});
}
: () => {
eval_logs().then((logresult) => {
// Set the list of logs
setLogs(logresult);
: async () => {
// Set the list of logs
const logresult = await eval_logs();
setLogs(logresult);

// Read header information for the logs
// and then update
const updatedHeaders = logHeaders;
Promise.all(
logresult.files.map(async (file) => {
try {
const result = await eval_log(file.name, true);
return { file: file.name, result };
} catch { }
})
).then((headerResults) => {
for (const headerResult of headerResults) {
if (headerResult) {
updatedHeaders[headerResult.file] = headerResult.result;
}
}
setLogHeaders({ ...updatedHeaders });
});
});
};

// initial fetch of logs
loadLogs();
await loadLogs();

// poll every 1s for events
setInterval(() => {
Expand Down

0 comments on commit 2a0b6b9

Please sign in to comment.