Skip to content

Conversation

@kris-brown
Copy link
Collaborator

This PR simplifies a lot of the structure of the CatColabInterop.jl package.

It introduces a new analysis of schema instances by sending the diagram to Catlab, where it is processed by @acset_colim to produce a tabular instance.

(This is currently a WIP - once the workflow is working for the tabular view analysis, the existing Decapodes analysis will be brought back into functionality).

@github-actions
Copy link

github-actions bot commented Nov 8, 2025

@kris-brown kris-brown self-assigned this Nov 8, 2025
@kris-brown kris-brown added the enhancement New feature or request label Nov 8, 2025
@epatters epatters force-pushed the update-cclinterop-types branch from 967ea9f to 113a4f8 Compare November 11, 2025 12:20
@epatters epatters added the external Work on interfacing with other tools label Nov 26, 2025
@kris-brown kris-brown changed the base branch from update-cclinterop-types to main December 12, 2025 18:33
@kris-brown kris-brown marked this pull request as ready for review December 12, 2025 18:33
@github-actions github-actions bot temporarily deployed to netlify-preview December 16, 2025 01:02 Destroyed
@github-actions github-actions bot temporarily deployed to netlify-preview December 18, 2025 22:21 Destroyed
@github-actions github-actions bot temporarily deployed to netlify-preview December 19, 2025 21:18 Destroyed
@github-actions github-actions bot temporarily deployed to netlify-preview December 19, 2025 21:25 Destroyed
CLEANUP: changing tests

CLEANUP: reorganized code into parse and execute folders

refactor algjuliainterop
CORS and async issues resolved

basic tabular view functionality

edit

remove decapodes material

run formatter

docs fix

using local version

remove axios
undo changes

newlines

remove space

More docs
@github-actions github-actions bot temporarily deployed to netlify-preview January 6, 2026 23:12 Destroyed
Copy link
Member

@kasbah kasbah left a comment

Choose a reason for hiding this comment

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

Some more CORS fixups for you.

@kris-brown
Copy link
Collaborator Author

Thanks, these are addressed now!

Copy link
Member

@epatters epatters left a comment

Choose a reason for hiding this comment

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

Thanks Kris and Matt, it'll be great to have a simpler and more flexible approach to interop with Julia. Some comments below.

const model = props.liveDiagram.liveModel.elaboratedModel();
if (model === undefined) {
throw "Bad model";
}
Copy link
Member

Choose a reason for hiding this comment

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

You don't want to throw an error here and this code looks redundant anyway since you're already extracting the elaborated model in the Solid resource. I think you can just delete the above lines:

    const model = props.liveDiagram.liveModel.elaboratedModel();
    if (model === undefined) {
        throw "Bad model";
    }


export const tabularView = (
options: AnalysisOptions,
): DiagramAnalysisMeta<GraphLayoutConfig.Config> => ({
Copy link
Member

Choose a reason for hiding this comment

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

Using the graph layout config doesn't make sense. Presumably a holdover from copy-pate.

If I'm not mistaken, this analysis has no content/state of its own, so you can replace

DiagramAnalysisMeta<GraphLayoutConfig.Config>

with

DiagramAnalysisMeta<{}>

): DiagramAnalysisMeta<GraphLayoutConfig.Config> => ({
...options,
component: (props) => <TabularView title={options.name} {...props} />,
initialContent: GraphLayoutConfig.defaultConfig,
Copy link
Member

Choose a reason for hiding this comment

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

This then becomes

initialContent: {},

}

/** Given a schema (DblModel of ThSchema), a JSON output `rawdata` from Catlab,
and a particular object `obname` in the schema, create an HTML table with
Copy link
Member

Choose a reason for hiding this comment

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

Docstring seems to end mid-sentence.

},

async ([model, diagram]) => {
const response = await fetch("http://127.0.0.1:8080/acsetcolim", {
Copy link
Member

Choose a reason for hiding this comment

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

Since this feature currently requires a server running locally, I think we should treat it as "experimental" and thus not show this analysis in prod. I'll suggest elsewhere how to do that.

```sh
julia --project -e 'import Pkg; Pkg.instantiate()'
```
[AlgebraicJulia](https://www.algebraicjulia.org/) available to CatColab.At this
Copy link
Member

Choose a reason for hiding this comment

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

Typo: missing space after "CatColab."

(m) =>
obname ===
model
.obGeneratorLabel(model.morPresentation(m)?.dom.content.toString() || "")
Copy link
Member

Choose a reason for hiding this comment

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

As another rule of thumb, you should never have to call toString() when working with presentations. Calling it suggests that you haven't narrowed the type enough. I'd rewrite the above predicate as

(id) => {
    const mor = model.morPresentation(id);
    return mor.dom.type === "Basic" && obname === model.obGeneratorLabel(mor.dom.content);
}

(But that's assuming that you're still keying by object labels, which I wouldn't recommend. See my other comment.)

/** Given a schema (DblModel of ThSchema), a JSON output `rawdata` from Catlab,
and a particular object `obname` in the schema, create an HTML table with
*/
function createACSetTable(model: DblModel, rawdata: object, obname: string) {
Copy link
Member

Choose a reason for hiding this comment

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

It's a code smell that rawdata has type object. You should have a type def of the format of the data expected to be returned from CatColab.

*/
function createACSetTable(model: DblModel, rawdata: object, obname: string) {
// The primary key of this table is given by `rawdata[obname]`
const rows: Array<string> = rawdata[obname as keyof typeof rawdata];
Copy link
Member

Choose a reason for hiding this comment

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

As a rule of thumb, when working with models, you should always key mappings by ID rather than human-readable label, which (1) are not guaranteed to be unique and (2) are structured objects (currently, lists of strings, rather than strings).

I would suggest that the last argument to this function be obId: string rather than obname and then

const rows: Map<string, string> = new Map();

Note that Maps in JavaScript (unlike JSON objects) are guaranteed to preserve the insertion order, so you don't need to worry about losing ordering.


// Convert morgenerators to user-friendly names
const headers = [obname].concat(
outhoms.map((m) => model.morGeneratorLabel(m)?.toString() || ""),
Copy link
Member

Choose a reason for hiding this comment

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

We should probably have a helper function for this, but the correct way to get a human-friendly name is

model.morGeneratorLabel(m)?.join(".") ?? ""

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request external Work on interfacing with other tools

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants