Skip to content

Commit

Permalink
Add Graphviz test file (#1368)
Browse files Browse the repository at this point in the history
  • Loading branch information
lutzroeder committed Sep 29, 2024
1 parent dadc151 commit f074162
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 0 deletions.
36 changes: 36 additions & 0 deletions source/graphviz.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@

const graphviz = {};

graphviz.ModelFactory = class {

match(context) {
const reader = context.read('text', 0x10000);
if (reader) {
try {
const line = reader.read('\n');
if (line === undefined) {
return;
}
if (line.indexOf('digraph') !== -1) {
context.type = 'graphviz.dot';
}
} catch {
// continue regardless of error
}
}
}

async open(/* context */) {
throw new graphviz.Error('Invalid file content. File contains Graphviz data.');
}
};

graphviz.Error = class extends Error {

constructor(message) {
super(message);
this.name = 'Error loading Graphviz model.';
}
};

export const ModelFactory = graphviz.ModelFactory;
1 change: 1 addition & 0 deletions source/view.js
Original file line number Diff line number Diff line change
Expand Up @@ -5778,6 +5778,7 @@ view.ModelFactoryService = class {
this.register('./safetensors', ['.safetensors', '.safetensors.index.json']);
this.register('./tvm', ['.json', '.params']);
this.register('./modular', ['.maxviz']);
this.register('./graphviz', ['.dot']);
this.register('./catboost', ['.cbm']);
this.register('./weka', ['.model']);
this.register('./qnn', ['.json', '.bin', '.serialized']);
Expand Down
8 changes: 8 additions & 0 deletions test/models.json
Original file line number Diff line number Diff line change
Expand Up @@ -2088,6 +2088,14 @@
"format": "Flux",
"link": "https://github.com/lutzroeder/netron/issues/334"
},
{
"type": "graphviz",
"target": "resnet18.dot",
"source": "https://github.com/user-attachments/files/17175694/resnet18.dot.zip[resnet18.dot]",
"format": "Graphviz",
"error": "Invalid file content. File contains Graphviz data.",
"link": "https://github.com/lutzroeder/netron/issues/1368"
},
{
"type": "gguf",
"target": "mixtral-8x7b-v0.1.Q4_K_M.gguf",
Expand Down

0 comments on commit f074162

Please sign in to comment.