Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bug]: invokeai-batch command creates a logfile incompatible with windows filenames and fails #3005

Closed
1 task done
EdSisson opened this issue Mar 22, 2023 · 3 comments
Closed
1 task done
Assignees
Labels
bug Something isn't working

Comments

@EdSisson
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

OS

Windows

GPU

cuda

VRAM

12

What version did you experience this issue on?

2.3.2

What happened?

When in the developer CLI on windows, you should be able to call invokeai-batch according to the following syntax
invokeai-batch example.yml --invoke
where example.yml is a suitably formatted yaml, in this case, the output of
invokeai-batch --example > example.yml

When run without the --invoke command, the command creates a list of prompts from the combinations contained in the yaml, exactly as intended, but when called with invoke you get an error, an example of which is:
`(.venv) C:\Users\Administrator\invokeai>invokeai-batch example.yml --invoke

Spawning 1 invokeai processes across 1 CUDA gpus
Outputs will be written into default InvokeAI outputs directory, and error logs will be written to C:\Users\ADMINI1\AppData\Local\Temp\invokeai-batch-logs
Process 10212 running on GPU 0; logging to C:\Users\ADMINI
1\AppData\Local\Temp\invokeai-batch-logs\2023-03-22-11:18:34-pid=10212.txt
Process Process-1:
Traceback (most recent call last):
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python310\lib\multiprocessing\process.py", line 314, in _bootstrap
self.run()
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python310\lib\multiprocessing\process.py", line 108, in run
self._target(*self._args, **self._kwargs)
File "C:\Users\Administrator\invokeai.venv\lib\site-packages\ldm\invoke\dynamic_prompts.py", line 169, in _run_invoke
with open(logfile, "w") as stderr, redirect_stderr(stderr):
OSError: [Errno 22] Invalid argument: 'C:\Users\ADMINI~1\AppData\Local\Temp\invokeai-batch-logs\2023-03-22-11:18:34-pid=10212.txt'
╭─────────────────────────────── Traceback (most recent call last) ────────────────────────────────╮
│ C:\Users\Administrator\AppData\Local\Programs\Python\Python310\lib\runpy.py:196 in │
│ _run_module_as_main │
│ │
│ 193 │ main_globals = sys.modules["main"].dict
│ 194 │ if alter_argv: │
│ 195 │ │ sys.argv[0] = mod_spec.origin │
│ ❱ 196 │ return _run_code(code, main_globals, None, │
│ 197 │ │ │ │ │ "main", mod_spec) │
│ 198 │
│ 199 def run_module(mod_name, init_globals=None, │
│ │
│ C:\Users\Administrator\AppData\Local\Programs\Python\Python310\lib\runpy.py:86 in _run_code │
│ │
│ 83 │ │ │ │ │ loader = loader, │
│ 84 │ │ │ │ │ package = pkg_name, │
│ 85 │ │ │ │ │ spec = mod_spec) │
│ ❱ 86 │ exec(code, run_globals) │
│ 87 │ return run_globals │
│ 88 │
│ 89 def _run_module_code(code, init_globals=None, │
│ │
│ in :7 │
│ │
│ 4 from ldm.invoke.dynamic_prompts import main │
│ 5 if name == 'main': │
│ 6 │ sys.argv[0] = re.sub(r'(-script.pyw|.exe)?$', '', sys.argv[0]) │
│ ❱ 7 │ sys.exit(main()) │
│ 8 │
│ │
│ C:\Users\Administrator\invokeai.venv\lib\site-packages\ldm\invoke\dynamic_prompts.py:245 in │
│ main │
│ │
│ 242 │ │ parser.print_help() │
│ 243 │ │ sys.exit(-1) │
│ 244 │ │
│ ❱ 245 │ expand_prompts( │
│ 246 │ │ template_file=opt.template_file, │
│ 247 │ │ run_invoke=opt.invoke, │
│ 248 │ │ invoke_model=opt.model, │
│ │
│ C:\Users\Administrator\invokeai.venv\lib\site-packages\ldm\invoke\dynamic_prompts.py:102 in │
│ expand_prompts │
│ │
│ 99 │ │ │ sequence = 0 │
│ 100 │ │ │ for command in commands: │
│ 101 │ │ │ │ sequence += 1 │
│ ❱ 102 │ │ │ │ parent_conn.send( │
│ 103 │ │ │ │ │ command + f' --fnformat="dp.{sequence:04}.{{prompt}}.png"' │
│ 104 │ │ │ │ ) │
│ 105 │ │ │ parent_conn.close() │
│ │
│ C:\Users\Administrator\AppData\Local\Programs\Python\Python310\lib\multiprocessing\connection.py │
│ :206 in send │
│ │
│ 203 │ │ """Send a (picklable) object""" │
│ 204 │ │ self._check_closed() │
│ 205 │ │ self._check_writable() │
│ ❱ 206 │ │ self._send_bytes(_ForkingPickler.dumps(obj)) │
│ 207 │ │
│ 208 │ def recv_bytes(self, maxlength=None): │
│ 209 │ │ """ │
│ │
│ C:\Users\Administrator\AppData\Local\Programs\Python\Python310\lib\multiprocessing\connection.py │
│ :280 in _send_bytes │
│ │
│ 277 │ │ │ _CloseHandle(self._handle) │
│ 278 │ │ │
│ 279 │ │ def _send_bytes(self, buf): │
│ ❱ 280 │ │ │ ov, err = _winapi.WriteFile(self._handle, buf, overlapped=True) │
│ 281 │ │ │ try: │
│ 282 │ │ │ │ if err == _winapi.ERROR_IO_PENDING: │
│ 283 │ │ │ │ │ waitres = _winapi.WaitForMultipleObjects( │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯
BrokenPipeError: [WinError 232] The pipe is being closed`

the key to the problem is that windows can't have ':' in filepaths, so the tool is trying to create a logfile that isn't permitted in Windows:
OSError: [Errno 22] Invalid argument: 'C:\\Users\\ADMINI~1\\AppData\\Local\\Temp\\invokeai-batch-logs\\2023-03-22-11:18:34-pid=10212.txt'

The same service works very neatly indeed on Ubuntu and has no issues creating the logfile, as is expected because ':' is permitted in filepaths in Ubuntu.

Screenshots

No response

Additional context

No response

Contact Details

One Eye#3268

@EdSisson EdSisson added the bug Something isn't working label Mar 22, 2023
@lstein lstein self-assigned this Mar 24, 2023
@lstein
Copy link
Collaborator

lstein commented Mar 24, 2023

Arrrrgh. I'm sorry I didn't think of this and even sorrier I didn't test on Windows. A fix is forthcoming.

lstein added a commit that referenced this issue Mar 24, 2023
- `invokeai-batch --invoke` was created a time-stamped logfile with colons in its
  name, which is a Windows no-no. This corrects the problem by writing
  the timestamp out as "13-06-2023_8-35-10"

- Closes #3005
lstein added a commit that referenced this issue Mar 24, 2023
…3018)

- The command `invokeai-batch --invoke` was created a time-stamped
logfile with colons in its name, which is a Windows no-no. This corrects
the problem by writing the timestamp out as "13-06-2023_8-35-10"

- Closes #3005
@EdSisson
Copy link
Author

Arrrrgh. I'm sorry I didn't think of this and even sorrier I didn't test on Windows. A fix is forthcoming.

Please don't apologise, you're all doing great work and we're all very grateful. Thanks for the swift attention!

@lstein
Copy link
Collaborator

lstein commented Mar 28, 2023

This should now be fixed in the 2.3.3. release candidate.

@lstein lstein closed this as completed Mar 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants