{"id":20899446,"url":"https://github.com/wasasquatch/asterr","last_synced_at":"2025-06-25T05:03:42.566Z","repository":{"id":197320153,"uuid":"698432869","full_name":"WASasquatch/ASTERR","owner":"WASasquatch","description":"Abstract Syntax Trees Evaluated Restricted Run (ASTERR) is a Python Script executor for ComfyUI","archived":false,"fork":false,"pushed_at":"2024-10-27T01:48:56.000Z","size":30,"stargazers_count":30,"open_issues_count":6,"forks_count":9,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-06-25T05:03:22.849Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/WASasquatch.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-09-29T23:06:53.000Z","updated_at":"2025-06-03T07:52:20.000Z","dependencies_parsed_at":null,"dependency_job_id":"6a4e2266-3137-42d9-9834-fdf3c34c6517","html_url":"https://github.com/WASasquatch/ASTERR","commit_stats":null,"previous_names":["wasasquatch/asterr"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/WASasquatch/ASTERR","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WASasquatch%2FASTERR","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WASasquatch%2FASTERR/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WASasquatch%2FASTERR/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WASasquatch%2FASTERR/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/WASasquatch","download_url":"https://codeload.github.com/WASasquatch/ASTERR/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WASasquatch%2FASTERR/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261807929,"owners_count":23212683,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-18T11:14:05.213Z","updated_at":"2025-06-25T05:03:42.508Z","avatar_url":"https://github.com/WASasquatch.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ASTERR\n Abstract Syntax Trees Evaluated Restricted Run (ASTERR) is a Python Script executor for ComfyUI\n\n\u003e [!WARNING] \n\u003e ASTERR runs Python Code from a Web Interface! It is highly recommended to run this in a closed-off environment, as it could have potential security risks.\n\n# Installation\n\nClone the reposity to `ComfyUI/custom_nodes` and restart ComfyUI if running.\n\n# Configuration\n\nThe default configuration specifies a maximum recursion limit of 100 for loops and nested operations. The allowed modules list is empty, and uses the internal default allowed imports.\n\n**DEFAULT CONFIG:**\n```json\n{\n\t\"recursion_limit\": 100,\n\t\"allowed_modules\": []\n}\n```\n\nYou can added allowed modules by their name, and optionally plus their submodule. For exmaple to allow PIL import and it's submodules you could either do\n```json\n\t\"allowed_modules\": [\"PIL\", \"PIL.Image\", \"PIL.ImageFilter\"]\n```\nAnd so on, or you could do\n```json\n\t\"allowed_modules\": [\"PIL.*\"]\n```\n\n***To live dangerously and allow any imports like a og boss, you can use:***\n```json\n\t\"allowed_modules\": [\"*\"]\n```\n\n---\n\n# Nodes\n\n## `ASTERR Script` Node\n\n### Required Params\n - `script` (`STRING`): The script to process. Can be converted to input to provide custom text string input.\n### Optional params\n - `trigger_run_01` (`INT`): `0` or `1` `INT` that defines whether the script should run or not.\n - `a` through `k` (`*`): Arbitrary input (`STRING`, `INT`, `FLOAT`, `IMAGE`, `MODEL`, etc) to pass as a variable to the execution namespace.\n\u003e [!WARNING]\n\u003e Be sure to expect and handle the data you input. If `a` is a `IMAGE` tensor input, we need to handle the batched tensor ASTERR will receive accordingly.\n - `preset_script` (`COMBO`): List of `.py` scripts located in `ASTERR/scripts` for preset execution. This will override the `script` input.\n - `always_run` (`COMBO`): `false` or `true` on whether to always run the script (similar to trigger on run, but a constant state). If false, it will only run when a change has been made.\n### Hidden params\n - Accessible within scripts is `prmpt` and `extra_pnginfo` vars which can be used to investigate, fetch data. In the case of `extra_pnginfo` you can overwrite the variable with an updated version of the `extra_pnginfo` (`dict`) to return with the node to the executor. \n\n## `Save ASTERR Script` Node\n\nSave a ASTERR script which would then be available under `ASTERR/scripts` and the `preset_scripts` menu in the [ASTERR Script](https://github.com/WASasquatch/ASTERR#ASTERR-Script) node.\n\n### Required Params\n - `script_string` (`STRING`): Script content string input. This string is saved to a python script file under `ASTERR/scripts`\n - `script_name` (`STRING`): Script name to use, does not include the extension.\n - `overwrite_script` (`COMBO`): `false` or `true` on whether to overwrite the script that already exists on disk.\n\n---\n\n# PRESET SCRIPTS\n\nPreset scripts allow you to pre-define functions to pick from and run any time. Scripts are saved a `.py` files (so editing is familiar).\n\n### Return methods\n- `asterr_result` var can be used to define the result to return to the node.\n- `extra_pnginfo` can be used and overwritten to return edited extra_pnginfo\n\n## Available Scripts\n\n- **resize_maxsize.py**\n  - Resize input `a` (`IMAGE`) propotionally with `b` (`INT`) as max size of the result.\n\n### Script Code\n```python\n# Inside functions, we must import our modules as they are scoped from the main script\n# tensor2pil() and pil2tensor() are built-in methods to help with `IMAGE` input\n\n# a = image (tensor batched image)\n# b = max size (INT)\n\ndef resizeImage(image, max_size):\n    import PIL\n    width, height = image.size\n    new_width, new_height = width, height\n\n    if width \u003e max_size or height \u003e max_size:\n        ratio = min(max_size / width, max_size / height)\n        new_width = int(width * ratio)\n        new_height = int(height * ratio)\n\n    elif max_size \u003e max(width, height):\n        ratio = max_size / max(width, height)\n        new_width = int(width * ratio)\n        new_height = int(height * ratio)\n\n    resized_image = image.resize((new_width, new_height))\n    return resized_image\n\n\n# We define the result to return to the node with the `asterr_result` var\nasterr_result = pil2tensor(resizeImage(tensor2pil(a), b))\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwasasquatch%2Fasterr","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwasasquatch%2Fasterr","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwasasquatch%2Fasterr/lists"}