Skip to content

Conversation

feloy
Copy link
Contributor

@feloy feloy commented May 28, 2025

Signed-off-by: Philippe Martin [email protected]

What does this PR do?

Reads the catalogs during the call to catalogManager.init(), so the models are available for modelsManager at init time

Screenshot / video of UI

What issues does this PR fix or reference?

Fixes #2937

How to test this PR?

The problem in #2937 is reproducible only when a valid user catalog file exists. Download models, then create a user catalog file, and start Podman Desktop with AI Lab. The warnings of model not found should have disappeared

Signed-off-by: Philippe Martin <[email protected]>
@feloy feloy requested review from benoitf, jeffmaury and a team as code owners May 28, 2025 09:15
@feloy feloy requested review from cdrage and gastoner May 28, 2025 09:15
Copy link
Contributor

@gastoner gastoner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM on Linux

Copy link
Contributor

@axel7083 axel7083 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice change, LGTM

this.#jsonWatcher.init();

await this.readCatalogs();
}
Copy link
Contributor

@axel7083 axel7083 May 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

async init(): Promise<void> {
  return new Promise<void>((resolve) => {
    // Creating a json watcher
    this.#jsonWatcher = new JsonWatcher(this.getUserCatalogPath(), {
      version: CatalogFormat.CURRENT,
      recipes: [],
      models: [],
      categories: [],
    });
    
    this.#jsonWatcher.onContentUpdated(content => {
      resolve();
      this.onUserCatalogUpdate(content);
    });
    this.#jsonWatcher.init();
  });
}

can't we just wrap the JSON watcher instead of reading manually the file??

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, great idea. Just moving resolve() after onSuerCatalogUpdate()

Copy link
Contributor

@axel7083 axel7083 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@feloy feloy requested a review from axel7083 May 28, 2025 12:22
import { afterEach, beforeEach, expect, test, vi, describe, type MockInstance } from 'vitest';
import { Studio } from './studio';
import { type ExtensionContext, EventEmitter, version } from '@podman-desktop/api';
import * as catalogManager from './managers/catalogManager';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why importing everything using *?

Suggested change
import * as catalogManager from './managers/catalogManager';
import { CatalogManager } from './managers/catalogManager';
[...]
vi.mocked(CatalogManager).mockReturnValue(...)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

right, a residue of a another try, reverting...

Signed-off-by: Philippe Martin <[email protected]>
@feloy feloy force-pushed the fix-2937/model-not-found-init branch from 6d83534 to dcbb838 Compare May 28, 2025 13:25
Copy link
Collaborator

@jeffmaury jeffmaury left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor

@axel7083 axel7083 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM ! Thanks for including the changes

@feloy feloy enabled auto-merge (squash) May 28, 2025 13:29
@feloy feloy merged commit 1729873 into containers:main May 28, 2025
7 checks passed
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

Successfully merging this pull request may close these issues.

Unexpected Can't find model info for local folder message at startup
4 participants