Skip to content

Commit

Permalink
Fixing bug in generation of types using some plugins. Releasing as v0…
Browse files Browse the repository at this point in the history
….2.13
  • Loading branch information
karurochari committed Sep 13, 2024
1 parent 4408be7 commit 5c10dfe
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 10 deletions.
14 changes: 10 additions & 4 deletions TODO.md
Original file line number Diff line number Diff line change
@@ -1,25 +1,31 @@
# Upcoming

## Needed for release 0.2.13
## Needed for release 0.2.15

- [ ] Companion plugin for Comfy to simplify testing.
- [ ] Optional support to add/strip metadata in the final artifacts if so desired.

## Needed for release 0.2.17

- [ ] Add tests for the workflow building
- [ ] Add tests for ts code gen from workflow

## Needed for release 0.2.15
## Needed for release 0.2.19

- [ ] Use names from the workflow for nodes during code gen.
- [ ] Generate more of the boilerplate during code gen.
- [ ] Optional support to add/strip metadata in the final artifacts if so desired.
- [ ] Better error handling when workflows fail (and related tests)

## Needed for release 0.3.x

- [ ] Add support for client-side certificates to authorize the connection with comfyui (needed for some semi-public configurations)
- [ ] Add interpolation support for pre-compiled workflows. Needed to generate many variants fast (?)

# Older releases

## Needed for release 0.2.13

- [x] Fixing codegen for some plugins

## Needed for release 0.2.11

- [x] Improve docs for recent features
Expand Down
2 changes: 1 addition & 1 deletion docs/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ bunx comfybun gen-types DEST_FILE --url=HOST:PORT --packageName=comfyclient
```

`url` and `packageName` have sound defaults.
If `DEST_FILE` is not specified a `workflow.ts` file will be generated locally.
If `DEST_FILE` is not specified a `comfy-types.ts` file will be generated locally.

### Code from image

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"module": "index.ts",
"type": "module",
"license": "BSD-3-Clause",
"version": "0.2.12",
"version": "0.2.13",
"description": "Wrapper for the REST endpoints of a comfyui instance & some quality of life utils.",
"bin": {
"comfybun": "./bin/main.ts"
Expand Down
24 changes: 20 additions & 4 deletions src/comfy-types-gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,26 @@ export function CompileComfyJSON(cfg: ReturnType<typeof NormalizeComfyJSON>, bas

function TypeFromComfyUI(type: string | string[], metadata?: { min?: unknown, max?: unknown, default?: unknown, step?: unknown }) {
if (typeof type === 'string') {
if (['STRING', 'BOOLEAN', 'INT', 'FLOAT', '*'].includes(type) === false) types.add(type);
if (type === '*') return 'ANY'
else if (metadata?.min !== undefined && metadata?.max !== undefined) return `${type}<${metadata.min},${metadata.max}>`;
else return type;
const type_list = type.split(",");
const ret_list = []
for (const type of type_list) {
const reduced_type = type.split(":")[0]
if (
["STRING", "BOOLEAN", "INT", "FLOAT", "*"].includes(
reduced_type,
) === false
)
types.add(reduced_type);

if (reduced_type === "*") ret_list.push("ANY");
else if (
metadata?.min !== undefined &&
metadata?.max !== undefined
)
ret_list.push(`${reduced_type}<${metadata.min},${metadata.max}>`);
else ret_list.push(reduced_type);
}
return ret_list.join('|');
}
else {
if (type.length !== 0) return `${type.map(x => `'${$(x)}'`).join('|')}| $dyn`
Expand Down

0 comments on commit 5c10dfe

Please sign in to comment.