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

PythonVirtualenvOperator - SyntaxError: cannot assign to operator #42796

Closed
2 tasks done
k-slash opened this issue Oct 7, 2024 · 5 comments · Fixed by #42902
Closed
2 tasks done

PythonVirtualenvOperator - SyntaxError: cannot assign to operator #42796

k-slash opened this issue Oct 7, 2024 · 5 comments · Fixed by #42902
Assignees
Labels
area:core area:core-operators Operators, Sensors and hooks within Core Airflow good first issue kind:bug This is a clearly a bug

Comments

@k-slash
Copy link

k-slash commented Oct 7, 2024

Apache Airflow version

Other Airflow 2 version (please specify below)

If "Other Airflow 2 version" selected, which one?

2.8.4 and 2.9.3

What happened?

I’m not sure if this error is known, but when I use the PythonVirtualenvOperator, I get the following error: "SyntaxError: cannot assign to operator" if the file where I create the DAG contains a hyphen in its name. When I remove the hyphen, the error disappears.

How to reproduce

  1. Create a new DAG file in your Airflow project with a hyphen (-) in its name (e.g., my-dag.py).
  2. Define a DAG inside the file and include the PythonVirtualenvOperator in one of the tasks.
  3. Trigger the DAG or run it.
  4. You will encounter the following error: SyntaxError: cannot assign to operator.
  5. Rename the DAG file to remove the hyphen (e.g., my_dag.py), then run it again.
  6. The error no longer occurs.

Operating System

Debian GNU/Linux 12.6

Deployment

Official Apache Airflow Helm Chart

Are you willing to submit PR?

  • Yes I am willing to submit a PR!

Code of Conduct

@k-slash k-slash added area:core kind:bug This is a clearly a bug needs-triage label for new issues that we didn't triage yet labels Oct 7, 2024
Copy link

boring-cyborg bot commented Oct 7, 2024

Thanks for opening your first issue here! Be sure to follow the issue template! If you are willing to raise PR to address this issue please do so, no need to wait for approval.

@dosubot dosubot bot added the area:core-operators Operators, Sensors and hooks within Core Airflow label Oct 7, 2024
@potiuk potiuk added good first issue and removed needs-triage label for new issues that we didn't triage yet labels Oct 7, 2024
@potiuk
Copy link
Member

potiuk commented Oct 7, 2024

Likely because the generated dynamically Python script generates a name that is not valid Python identifier. Should be easy to fix by slugifying the identifier generated, so maybe someone will take a look. Marked it as "good first issue".

@k-slash
Copy link
Author

k-slash commented Oct 8, 2024

Thanks for the explanation. I hope this issue will be useful to others who encounter this problem in the meantime.

@jason810496
Copy link
Contributor

Hi @potiuk , could you please assign this issue to me?I am a new contributor and have just reproduced the issue. I'm currently investigating it.

@k-slash
Copy link
Author

k-slash commented Oct 15, 2024

Thank you for solving the issue, @jason810496. Looking forward to seeing the fix in the next version of Airflow! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:core area:core-operators Operators, Sensors and hooks within Core Airflow good first issue kind:bug This is a clearly a bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants