Ich arbeite an einer Flask -Anwendung, die Sellerie zur Verarbeitung von Hintergrundaufgaben verwendet. Ich stoße auf Probleme mit kreisförmigen Importen und Aufgaben, die keine Fehler gefunden haben. Hier ist die Struktur meines Projekts: < /p>
celery -A tasks.celery worker --loglevel=info
Usage: celery [OPTIONS] COMMAND [ARGS]...
Try 'celery --help' for help.
Error: Invalid value for '-A' / '--app':
Unable to load celery application.
While trying to load the module tasks.celery the following error occurred:
Traceback (most recent call last):
File "/Users/username/Local Documents/python_environments/pytorchenv/lib/python3.11/site-packages/celery/bin/celery.py", line 58, in convert
return find_app(value)
^^^^^^^^^^^^^^^
File "/Users/username/Local Documents/python_environments/pytorchenv/lib/python3.11/site-packages/celery/app/utils.py", line 383, in find_app
sym = symbol_by_name(app, imp=imp)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/username/Local Documents/python_environments/pytorchenv/lib/python3.11/site-packages/kombu/utils/imports.py", line 59, in symbol_by_name
module = imp(module_name, package=package, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/username/Local Documents/python_environments/pytorchenv/lib/python3.11/site-packages/celery/utils/imports.py", line 109, in import_from_cwd
return imp(module, package=package)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/[email protected]/3.11.9_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "", line 1204, in _gcd_import
File "", line 1176, in _find_and_load
File "", line 1147, in _find_and_load_unlocked
File "", line 690, in _load_unlocked
File "", line 940, in exec_module
File "", line 241, in _call_with_frames_removed
File "/Users/username/Documents/Python Scripts/apple-podcast-transcript-extractor/tasks.py", line 3, in
from app import app, extract_transcript, summarize_transcript
File "/Users/username/Documents/Python Scripts/apple-podcast-transcript-extractor/app.py", line 12, in
from tasks import process_ttml
ImportError: cannot import name 'process_ttml' from partially initialized module 'tasks' (most likely due to a circular import) (/Users/username/Documents/Python Scripts/apple-podcast-transcript-extractor/tasks.py)
< /code>
[list]
process_ttml
NameError
NameError: name 'process_ttml' is not defined
Traceback (most recent call last)
File "/Users/username/Local Documents/python_environments/pytorchenv/lib/python3.11/site-packages/flask/app.py", line 1498, in __call__
return self.wsgi_app(environ, start_response)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/username/Local Documents/python_environments/pytorchenv/lib/python3.11/site-packages/flask/app.py", line 1476, in wsgi_app
response = self.handle_exception(e)
^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/username/Local Documents/python_environments/pytorchenv/lib/python3.11/site-packages/flask/app.py", line 1473, in wsgi_app
response = self.full_dispatch_request()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/username/Local Documents/python_environments/pytorchenv/lib/python3.11/site-packages/flask/app.py", line 882, in full_dispatch_request
rv = self.handle_user_exception(e)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/username/Local Documents/python_environments/pytorchenv/lib/python3.11/site-packages/flask/app.py", line 880, in full_dispatch_request
rv = self.dispatch_request()
^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/username/Local Documents/python_environments/pytorchenv/lib/python3.11/site-packages/flask/app.py", line 865, in dispatch_request
return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args) # type: ignore[no-any-return]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/username/Documents/Python Scripts/apple-podcast-transcript-extractor/app.py", line 121, in upload_file
task = process_ttml.delay(file_path, include_timestamps)
^^^^^^^^^^^^
NameError: name 'process_ttml' is not defined
The debugger caught an exception in your WSGI application. You can now look at the traceback which led to the error.
To switch between the interactive traceback and the plaintext one, you can click on the "Traceback" headline. From the text traceback you can also create a paste of it. For code execution mouse-over the frame you want to debug and click on the console icon on the right side.
You can execute arbitrary Python code in the stack frames and there are some extra helpers available for introspection:
dump() shows all variables in the frame
dump(obj) dumps all that's known about the object
Brought to you by DON'T PANIC, your friendly Werkzeug powered traceback interpreter.
Frage:
Wie kann ich das kreisförmige Importproblem beheben und sicherstellen, dass die Aufgabe process_ttml korrekt definiert ist und in meiner Flask Anwendung mit Sellerie verwendet wird. Message Broker für Sellerie.
Der Redis -Server wird ausgeführt und zugänglich.>
Ich arbeite an einer Flask -Anwendung, die Sellerie zur Verarbeitung von Hintergrundaufgaben verwendet. Ich stoße auf Probleme mit kreisförmigen Importen und Aufgaben, die keine Fehler gefunden haben. Hier ist die Struktur meines Projekts: < /p>
# Find all elements in the TTML file paragraphs = root.findall(".//{http://www.w3.org/ns/ttml}p")
for paragraph in paragraphs: paragraph_text = "" for span in paragraph.findall(".//{http://www.w3.org/ns/ttml}span"): if span.text: paragraph_text += span.text.strip() + " "
paragraph_text = paragraph_text.strip() if paragraph_text: if include_timestamps and "begin" in paragraph.attrib: timestamp = format_timestamp(float(paragraph.attrib["begin"].replace("s", ""))) transcript.append(f"[{timestamp}] {paragraph_text}") else: transcript.append(paragraph_text)
return "\n\n".join(transcript)
except ET.ParseError as e: return f"Error parsing TTML file: {e}"
def summarize_transcript(transcript): max_chunk_size = 2000 # Adjust this value based on your token limit transcript_chunks = [transcript[i:i + max_chunk_size] for i in range(0, len(transcript), max_chunk_size)] summaries = []
for chunk in transcript_chunks: retry_count = 0 while retry_count < 5: # Retry up to 5 times try: response = client.chat.completions.create( model="gpt-4", messages=[ {"role": "system", "content": "You are a helpful assistant that summarizes podcast transcripts."}, {"role": "user", "content": f"Summarize the following podcast transcript in bullet points:\n\n{chunk}"} ], max_tokens=200 ) summaries.append(response.choices[0].message.content.strip()) break # Exit the retry loop if successful except RateLimitError as e: retry_count += 1 wait_time = 2 ** retry_count # Exponential backoff print(f"Rate limit exceeded. Retrying in {wait_time} seconds...") time.sleep(wait_time) except Exception as e: print(f"An error occurred: {e}") break
def make_celery(app): celery = Celery( app.import_name, backend=app.config['CELERY_RESULT_BACKEND'], broker=app.config['CELERY_BROKER_URL'] ) celery.conf.update(app.config) return celery [/code] [b] Problem: [/b] Wenn ich die Flash -Anwendung ausführe, erhalte ich den folgenden Fehler: [code]NameError: name 'process_ttml' is not defined [/code] Wenn ich versuche, dies durch [url=viewtopic.php?t=8986]Importieren[/url] von Process_ttml in App.py zu beheben, erhalte ich einen kreisförmigen Importfehler.[code]celery -A tasks.celery worker --loglevel=info Usage: celery [OPTIONS] COMMAND [ARGS]... Try 'celery --help' for help.
Error: Invalid value for '-A' / '--app': Unable to load celery application. While trying to load the module tasks.celery the following error occurred: Traceback (most recent call last): File "/Users/username/Local Documents/python_environments/pytorchenv/lib/python3.11/site-packages/celery/bin/celery.py", line 58, in convert return find_app(value) ^^^^^^^^^^^^^^^ File "/Users/username/Local Documents/python_environments/pytorchenv/lib/python3.11/site-packages/celery/app/utils.py", line 383, in find_app sym = symbol_by_name(app, imp=imp) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/username/Local Documents/python_environments/pytorchenv/lib/python3.11/site-packages/kombu/utils/imports.py", line 59, in symbol_by_name module = imp(module_name, package=package, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/username/Local Documents/python_environments/pytorchenv/lib/python3.11/site-packages/celery/utils/imports.py", line 109, in import_from_cwd return imp(module, package=package) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/homebrew/Cellar/[email protected]/3.11.9_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/importlib/__init__.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "", line 1204, in _gcd_import File "", line 1176, in _find_and_load File "", line 1147, in _find_and_load_unlocked File "", line 690, in _load_unlocked File "", line 940, in exec_module File "", line 241, in _call_with_frames_removed File "/Users/username/Documents/Python Scripts/apple-podcast-transcript-extractor/tasks.py", line 3, in from app import app, extract_transcript, summarize_transcript File "/Users/username/Documents/Python Scripts/apple-podcast-transcript-extractor/app.py", line 12, in from tasks import process_ttml ImportError: cannot import name 'process_ttml' from partially initialized module 'tasks' (most likely due to a circular import) (/Users/username/Documents/Python Scripts/apple-podcast-transcript-extractor/tasks.py) < /code> [list] process_ttml[/code] nicht gefunden [/list] [code] NameError
NameError: name 'process_ttml' is not defined Traceback (most recent call last)
File "/Users/username/Local Documents/python_environments/pytorchenv/lib/python3.11/site-packages/flask/app.py", line 1498, in __call__
The debugger caught an exception in your WSGI application. You can now look at the traceback which led to the error.
To switch between the interactive traceback and the plaintext one, you can click on the "Traceback" headline. From the text traceback you can also create a paste of it. For code execution mouse-over the frame you want to debug and click on the console icon on the right side.
You can execute arbitrary Python code in the stack frames and there are some extra helpers available for introspection:
dump() shows all variables in the frame dump(obj) dumps all that's known about the object
Brought to you by DON'T PANIC, your friendly Werkzeug powered traceback interpreter.
[/code] [b] Frage: [/b] Wie kann ich das kreisförmige Importproblem beheben und sicherstellen, dass die Aufgabe process_ttml korrekt definiert ist und in meiner Flask Anwendung mit Sellerie verwendet wird. Message Broker für Sellerie. Der Redis -Server wird ausgeführt und zugänglich.>
Ich habe einige APIs in Flask erstellt und wollte sie nun auf dem Server meines Unternehmens bereitstellen. Ich bin neu bei Flask und habe zuvor mit Spring Boot gearbeitet und weiß, dass wir JAR mit...
Ich möchte zwei Sellerie-Warteschlangen erstellen (für verschiedene Arten von Aufgaben)
Meine Sellerie-Konfiguration. Ich erwarte, dass diese Konfiguration zwei Warteschlangen „celery“ und „celery:1“...
Ich habe ein Problem mit Sellerie. Ich benutze Sellerie mit Amazon SQS. Ich habe alles über Sellerie und SQS eingerichtet. Aber sie erhalten von keinem Selleriearbeiter. Ich nehme an, ich muss die...
Ich habe einen Fastapi-Endpunkt erstellt, wie unten gezeigt:
@app.post( /report/upload )
def create_upload_files(files: UploadFile = File(...)):
try:
with open(files.filename,'wb+') as wf:...
Ich arbeite an einem Kryptowährungsgitter -Handelssystem, in dem Bots Reihenfolge Entitäten erstellen. Wenn eine Bestellung erstellt wird, löst sie ein Domain -Ereignis aus, um die Bestellung an den...