-
comcom newshould create a proper folder structure at cwd. -
implement RICH so we can print out better errors and what not. Try to use rich to implement trees to show the user what their outputs are going to look like if they
inspecta solved workflow. -
confirm that 'reroutes' in the extras table in raw workflow files work.
-
It appears as though link ids by default already "bypass" these kinds of reroutes, so it's unlikely we need to actually do anything.
if we can control the saved filename on upload, we can set the filename to the UUIDv5 of the resolved workflow that generated it. This will give us a guaranteed random name that is deterministically linked to the contents of the workflow. This way when the user wants to generate the image again, we can just generate the check to see if that file exists on the server. WAIT NO WE CANT - Because the external input files might change. Everything about the workflow would look the same, but the external file would be different, and thus produce the same UUIDv5, and the workflow wouldn't regenerate.
We may not be able to control the names of the remote files, but we can store links to remote files in metadata files.
BUT WHAT IF: we check the hash of the image live before loading them into workflows? I think we have to do this anyway:
- Calculate the hash of the image
- Compare it against the hash in the metadata file
- if it's not the same, upload the new image to Comfy and update the hash in the metadata file.
Now when the user wants to run a downstream workflow with an image input:
- The input filepath is found.
- The hash of the image on disk is calculated and compared against the hash in the metadata file.
- If the hashes are the same, we grab the comfyui image link from the metadata file.
- If they're not the same, upload the image to comfyui, and update the metadata file to include the new hash and the new comfyui link
Load Image can load images that are uploaded to the input folder, but cannot load images that were generated as """outputs""" from other workflows. If you want to use them there, you have to either:
- Re-upload the image via
<server>/image/upload(insane) - Switch the
load imagenode to aLoad Image (from Outputs)and append[output]to the end of the remote filename option 2 is also insane, but doesn't incur a runtime cost, we we're going to do that. For now we're including the ' [output]' string in the remote filename in the metadata, but in the future we're going to just include 'type' (which I believe is provided by the return data from the image gen) in the metadata, and just handle that in-code. We're also going to write something to swapLoad ImagetoLoad Image (from output)nodes on the fly if the loaded image is detected as an "output" image so the exchange is totally transparent to the user.
Figure out why running the same workflow twice, without changing either images or workflow data, causes it to run again if you run a different workflow in-between.
Actually, I don't need to figure this out. I already know. It's because running a second workflow unloads the state of the last one. We need to manage workflow state manually. We can do this by storing a hash of the entire workflow data and all input images in a metadata file and reading that before generating. Not sure where we're gonna store this metadata file. Maybe in a hidden folder???
I think we should do a few things:
- Resolve all input images on
WorkflowInstanceinit. This way we always have the paths available. - Generate a hash of the api workflow (that is, the entire resolved
CommonWorkflow.to_api_dictdict) PLUS the hashes of the input images. Store this hash in theWorkflowInstanceobject. - Now when we go to run a WorkflowInstance, we compare the cached hash to the current hash value. If they're the same, do the following: 3.1. Check to see if the output files exist on disk and have metadata files AND that the metadata hashes match the actual hashes of the images. 3.2. If any of these conditions fail, run the workflow. If they're not the same, run the workflow.
Workflow Instance Hash algorithm:
- Inside the WorkflowInstance.init method, generate the
CommonWorkflow.to_api_dictdict. Store this asa - Generate a hash of all the input images (actual image hashes, not the cached hash). Store this as
b. - Store
hash(a + b)asWorkflowInstance.hashNow, when we try to run the workflow:
The WorkflowInstance should also have a is_dirty property, which does the following:
- If the metadata file does not exist, return
True - If the hash in the metadata file does not match this instance's hash, return True.
- For each Output Image:
- Check to see if the output file exists. If it does not, return
True - Check to see if the output file has a metadata file. If it does not, return
True - Check to see if the output file's hash matches the actual hash of the image. If it does not, return
True
- Check to see if the output file exists. If it does not, return
- Return
False
The WorkflowInstance should have a .execute() method which takes a ComfyServer.
The WorkflowInstance.init should also recieve a path to it's future metadata file.
Note: metadata paths should be constructed as directories, not path.to.my.workflow because workflows can nest infinitely deep, and filenames can only be so long.
The recipe yaml format is both specifically structured and includes some special non-standard features. It would be incredibly useful to have some special syntax highlighting in vscode for editing recipe files. At minimum, some special highlighting for the different sections (values, load, input, output) of recipes. However, if at all possible, it would be excellent to turn this into an entire extension that resolves values on the fly to show you what your values will look like after interpolation, AND to hightlight errors/cycles.
- Consider renaming the
outputsfolder toworkspaceto better reflect the fact that you will be working in there. - This is also the place where you will be putting reference photos
outputs/references