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

Problems working with Django 3.2.5 #334

Closed
shawnmjones opened this issue Jul 10, 2021 · 6 comments
Closed

Problems working with Django 3.2.5 #334

shawnmjones opened this issue Jul 10, 2021 · 6 comments

Comments

@shawnmjones
Copy link

I installed Wooey with

  • Django 3.2.5
  • celery 4.4.7

I started Wooey and celery using the commands from the documentation.

When trying to run the testscript.py from the documentation, celery issues this error:

[2021-07-10 16:06:59,996: ERROR/ForkPoolWorker-2] Task wooey.tasks.submit_script[103166dc-3ced-4495-93ba-85e6dfdda380] raised unexpected: SuspiciousFileOperation("Could not derive file name from ''")
Traceback (most recent call last):
  File "/Users/smj/.virtualenvs/wooey-raintale/lib/python3.8/site-packages/celery/app/trace.py", line 412, in trace_task
    R = retval = fun(*args, **kwargs)
  File "/Users/smj/.virtualenvs/wooey-raintale/lib/python3.8/site-packages/celery/app/trace.py", line 704, in __protected_call__
    return self.run(*args, **kwargs)
  File "/Users/smj/.virtualenvs/wooey-raintale/lib/python3.8/site-packages/wooey/tasks.py", line 132, in submit_script
    print("job.output_path: {}".format(job.output_path))
  File "/Users/smj/.virtualenvs/wooey-raintale/lib/python3.8/site-packages/wooey/models/core.py", line 229, in output_path
    get_valid_filename(self.user.username if self.user is not None else ''),
  File "/Users/smj/.virtualenvs/wooey-raintale/lib/python3.8/site-packages/django/utils/functional.py", line 228, in wrapper
    return func(*args, **kwargs)
  File "/Users/smj/.virtualenvs/wooey-raintale/lib/python3.8/site-packages/django/utils/text.py", line 235, in get_valid_filename
    raise SuspiciousFileOperation("Could not derive file name from '%s'" % name)
django.core.exceptions.SuspiciousFileOperation: Could not derive file name from ''

If I downgrade Django to 3.1.8 as mentioned on Stack Overflow, then this problem does not occur.

@Chris7
Copy link
Member

Chris7 commented Jul 18, 2021

Thanks for the report. Could you provide your settings.py/pip freeze, and the script you are using? I just some tests locally with 3.2.5 but had no issues.

@shawnmjones
Copy link
Author

Thanks for getting back to me so quickly. I had to put together a MWE to make sure we nailed this down. I am running this on macOS 11.3, but my colleague first encountered this issue on her Ubuntu machine. I am running Python 3.9.2.

The output of pip freeze

amqp==2.6.1
asgiref==3.4.1
billiard==3.6.4.0
celery==4.4.7
clinto==0.4.0
Django==3.2.5
django-autoslug==1.9.8
django-celery-results==2.0.1
django-storages==1.11.1
jsonfield==2.1.1
kombu==4.6.11
pytz==2021.1
six==1.16.0
sqlparse==0.4.1
vine==1.3.0
wooey==0.12.0

The script I am using (the same from the documentation)

import argparse
import sys

parser = argparse.ArgumentParser(description="Find the sum of all the numbers below a certain number.")
parser.add_argument('--below', help='The number to find the sum of numbers below.', type=int, default=1000)

def main():
    args = parser.parse_args()
    s = sum((i for i in range(args.below)))
    print("Sum =", s)
    return 0

if __name__ == "__main__":
    sys.exit(main())

Full Celery Log



celery@tauntaun.lan v4.4.7 (cliffs)

macOS-11.3-x86_64-i386-64bit 2021-07-22 15:52:02

[config]
.> app:         ProjectName:0x10c488eb0
.> transport:   filesystem://localhost//
.> results:
.> concurrency: 1 (prefork)
.> task events: OFF (enable -E to monitor tasks in this worker)

[queues]
.> celery           exchange=celery(direct) key=celery


[tasks]
  . ProjectName.wooey_celery_app.debug_task
  . wooey.tasks.cleanup_dead_jobs
  . wooey.tasks.cleanup_wooey_jobs
  . wooey.tasks.submit_script

[2021-07-22 15:52:02,231: INFO/Beat] beat: Starting...
[2021-07-22 15:52:02,234: INFO/MainProcess] Connected to filesystem://localhost//
[2021-07-22 15:52:02,245: WARNING/MainProcess] /Users/smj/.virtualenvs/testing-wooey-django-issue/lib/python3.9/site-packages/celery/fixups/django.py:205: UserWarning: Using settings.DEBUG leads to a memory
            leak, never use this setting in production environments!
  warnings.warn('''Using settings.DEBUG leads to a memory
[2021-07-22 15:52:02,245: INFO/MainProcess] celery@tauntaun.lan ready.
[2021-07-22 15:53:59,651: INFO/MainProcess] Received task: wooey.tasks.submit_script[583928a1-0a26-40b2-867a-69b59974da66]
[2021-07-22 15:53:59,680: ERROR/ForkPoolWorker-2] Task wooey.tasks.submit_script[583928a1-0a26-40b2-867a-69b59974da66] raised unexpected: SuspiciousFileOperation("Could not derive file name from ''")
Traceback (most recent call last):
  File "/Users/smj/.virtualenvs/testing-wooey-django-issue/lib/python3.9/site-packages/celery/app/trace.py", line 412, in trace_task
    R = retval = fun(*args, **kwargs)
  File "/Users/smj/.virtualenvs/testing-wooey-django-issue/lib/python3.9/site-packages/celery/app/trace.py", line 704, in __protected_call__
    return self.run(*args, **kwargs)
  File "/Users/smj/.virtualenvs/testing-wooey-django-issue/lib/python3.9/site-packages/wooey/tasks.py", line 120, in submit_script
    cwd = job.get_output_path()
  File "/Users/smj/.virtualenvs/testing-wooey-django-issue/lib/python3.9/site-packages/wooey/models/core.py", line 229, in get_output_path
    path = self.output_path
  File "/Users/smj/.virtualenvs/testing-wooey-django-issue/lib/python3.9/site-packages/wooey/models/core.py", line 224, in output_path
    get_valid_filename(self.user.username if self.user is not None else ''),
  File "/Users/smj/.virtualenvs/testing-wooey-django-issue/lib/python3.9/site-packages/django/utils/functional.py", line 228, in wrapper
    return func(*args, **kwargs)
  File "/Users/smj/.virtualenvs/testing-wooey-django-issue/lib/python3.9/site-packages/django/utils/text.py", line 235, in get_valid_filename
    raise SuspiciousFileOperation("Could not derive file name from '%s'" % name)
django.core.exceptions.SuspiciousFileOperation: Could not derive file name from ''

@Chris7
Copy link
Member

Chris7 commented Aug 7, 2021

I managed to fall into this same scenario, but it was due to an error on my end where the celery configuration was not being picked up.

Do you have a celeryconfig file? I'm not sure how you are configured atm due to not having your user_settings.py (or wherever your settings.py for Django is coming from)

@Chris7
Copy link
Member

Chris7 commented Aug 7, 2021

Alright, I think I know what is up. You are using an anonymous user and there's a change in Django where it won't let '' go through anymore. I have a fix-a-lot-of-stuff MR #337 that addresses this.

@shawnmjones
Copy link
Author

Thanks for tracing this. I just verified that it does not happen to logged-in users.

@Chris7
Copy link
Member

Chris7 commented Aug 8, 2021

Thanks, closing this as fixed in master. Should be available in the next minor release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants