WASasquatch / was-node-suite-comfyui

An extensive node suite for ComfyUI with over 210 new nodes
MIT License
1.22k stars 177 forks source link

Improving Randomness & Wildcard File Reading in `WAS_Node_Suite.py` #198

Closed toxicwind closed 1 year ago

toxicwind commented 1 year ago
WASasquatch commented 1 year ago

Oh nice. I'll check this out when I am back home. Sounds nice.

toxicwind commented 1 year ago

Just for reference, the current randomness is fine for small wildcard files, the secrets library randomness only matters when you have a wildcards file that has a massive amount of lines, I noticed that the numpy random was causing a "noticeable" random.

WASasquatch commented 1 year ago

Just for reference, the current randomness is fine for small wildcard files, the secrets library randomness only matters when you have a wildcards file that has a massive amount of lines, I noticed that the numpy random was causing a "noticeable" random.

I noticed the same thing, like my popular location lists and natl parks, just repeating same "set" of places/parks.

toxicwind commented 1 year ago

Well it turns out that even the secrets module isnt random enough, the code changes above use SystemRandom which is supposedly cryptographically reliably random...

WASasquatch commented 1 year ago

Doesn't appear to be seeded which is a deal breaker. Need to be deterministic.

WASasquatch commented 1 year ago

I think the best way to improve randomness within X calls is probably simply a history utilizing the nodes persistent class to store X previous results, and ensuring a new result isn't within it (assuming total wildcards is above X history), then clear out oldest results from history as it's max size is exceeded.