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

Improved Python Error message #7907

Closed
4 tasks done
AlexCatarino opened this issue Apr 9, 2024 · 1 comment · Fixed by #8002
Closed
4 tasks done

Improved Python Error message #7907

AlexCatarino opened this issue Apr 9, 2024 · 1 comment · Fixed by #8002
Assignees
Labels

Comments

@AlexCatarino
Copy link
Member

Expected Behavior

We receive the exact location of the message

 self.SetHoldings("SPY", 1 / None)
                         ~~^~~
 in main.py: line 11

Actual Behavior

We read the following:

self.SetHoldings("SPY" in main.py: line 11

Potential Solution

Review the error parser to process Python 3.11 new format.

Reproducing the Problem

# region imports
from AlgorithmImports import *
# endregion

class CasualYellowGreenPenguin(QCAlgorithm):

    def Initialize(self):
        self.SetStartDate(2022, 10, 8)
        self.AddEquity("SPY")

    def OnData(self, data: Slice):
        self.SetHoldings("SPY", 1 / None)

Checklist

  • I have completely filled out this template
  • I have confirmed that this issue exists on the current master branch
  • I have confirmed that this is not a duplicate issue by searching issues
  • I have provided detailed steps to reproduce the issue
@AlexCatarino
Copy link
Member Author

There is another case where we receive this message:
Runtime Error: 'NoneType' object is not iterable

for:

class EnergeticBlackOwl(QCAlgorithm):
    def initialize(self):
        self.set_start_date(2024, 5, 1)
        self.add_equity("SPY")
        self.add_alpha(MyAlphaModel())

class MyAlphaModel(AlphaModel):
    def update(self, algorithm, data):
        return

the bug here is that update must return a list, and we don't have the full stack trace which we can only see in the syslog:

2024-05-08T12:12:48.4386968Z ERROR:: Extensions.SetRuntimeError(): Extensions.SetRuntimeError(): RuntimeError at 05/01/2024 13:31:00 UTC. Context: OnData Python.Runtime.PythonException: 'NoneType' object is not iterable
   at Python.Runtime.PythonException.ThrowLastAsClrException() in \src\runtime\PythonException.cs:line 52
   at Python.Runtime.PythonException.ThrowIfIsNull(NewReference& ob) in \src\runtime\PythonException.cs:line 470
   at Python.Runtime.PyIter.GetIter(PyObject iterable) in \src\runtime\PythonTypes\PyIter.cs:line 58
   at Python.Runtime.PyObject.GetIterator() in \src\runtime\PythonTypes\PyObject.cs:line 770
   at QuantConnect.Algorithm.Framework.Alphas.AlphaModelPythonWrapper.Update(QCAlgorithm algorithm, Slice data)+MoveNext() in /Algorithm/Alphas/AlphaModelPythonWrapper.cs:line 81

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

Successfully merging a pull request may close this issue.

2 participants