Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Migrate pythonnet to .NET Core 3.0 #33

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

Closed
wants to merge 92 commits into from

Conversation

gsalaz98
Copy link

@gsalaz98 gsalaz98 commented Jul 8, 2019

What does this implement/fix? Explain your changes.

Migrates and adds support for .NET Core 3.0 for pythonnet. This is required for python algorithms to run in LEAN .NET Core

Does this close any currently open issues?

No

Any other comments?

I believe this might break backwards compatibility with .NET Framework 4.5.2 -- which is what LEAN currently runs on. Will have to do some testing for that.

Checklist

Check all those that are applicable and complete.

  • Make sure to include one or more tests for your change
  • If an enhancement PR, please create docs and at best an example
  • Add yourself to AUTHORS
  • Updated the CHANGELOG

AlexCatarino and others added 30 commits July 23, 2018 22:24
Convertes System.Decimal to decimal.decimal and vice-versa
Converts System.DateTime and System.TimeSpan to datetime.datetime and datetime.timedelta and vice-versa
DECREF'ing datetime timezone argument when DateTimeKind is Unspecified was causing `Fatal Python error: deallocating None` because the object was set to `Runtime.PyNone`.

Fixed the input to datetime constructor as we were passing milliseconds, where it should be microseconds.
…-none-datetime-timezone

Do not include timezone if DateTimeKind is Unspecified
…sioning

Sets the version to 1.0.5.12 to match QuantConnect's nuget one.
- C# decimal conversion will use C# double and python float due to the
big performance impact of converting C# decimal to python decimal.
…ean-2825-decimal-csharp-to-python-float

C# decimal to Python conversion
Convertes System.Decimal to decimal.decimal and vice-versa
Converts System.DateTime and System.TimeSpan to datetime.datetime and datetime.timedelta and vice-versa
DECREF'ing datetime timezone argument when DateTimeKind is Unspecified was causing `Fatal Python error: deallocating None` because the object was set to `Runtime.PyNone`.

Fixed the input to datetime constructor as we were passing milliseconds, where it should be microseconds.
- C# decimal conversion will use C# double and python float due to the
big performance impact of converting C# decimal to python decimal.
- Increasing minor version to 14
- Adding `UnsafeDispose()` for `PyObject` which does not require
acquiring/releasing the lock
- Adding check before calling `SetArgsAndCause` for the `ClrObject`, the
call only makes sense when we are an exception and causes an overhead
…mprovements-dispose-clrobject

Performance improvements ClrObject - Dispose PyObj
Martin-Molinero and others added 26 commits April 23, 2019 18:33
…when-shutting-down

Fix deadlock when shuting down
This addresses the following scenario:

1. A C# object `a` is created and filled with some data.
2. `a` is passed via Python.NET to Python. To do that Python.NET
   creates a wrapper object `w`, and stores reference to `a` in one of
   its fields.
3. Python code later passes `w` back to C#, e.g. calls `SomeCSharpMethod(w)`.
4. Python.NET has to unwrap `w`, so it reads the reference to `a` from it.

Prior to this change in 4. Python.NET had to determine what kind of an
object `a` is. If it is an exception, a different offset needed to be
used. That check was very expensive (up to 4 calls into Python
interpreter).

This change replaces that check with computing offset unconditionally
by subtracting a constant from the object size (which is read from the wrapper),
thus avoiding calls to Python interpreter.
Improve Python.NET interop performance
Can load .NET Core into python

Pass clr PyObject back to Python
Copy link
Author

@gsalaz98 gsalaz98 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just an initial review. Expect more to come in the future

return;
}

if (!GetClrFilesAbsolutePath(pn_args->entry_path, "/home/gerry/dotnet/shared/Microsoft.NETCore.App/2.0.0", &pn_args->clr_path))
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to figure out a way to remove the hard coded path from here. I believe that we can pass NULL as the parameter value and it'll try to determine the path automatically.

@@ -22,10 +22,10 @@
# Allow config/verbosity to be set from cli
# http://stackoverflow.com/a/4792601/5208670
CONFIG = "Release" # Release or Debug
VERBOSITY = "minimal" # quiet, minimal, normal, detailed, diagnostic
VERBOSITY = "normal" # quiet, minimal, normal, detailed, diagnostic
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reset verbosity back to "minimal"?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see a good reason to change it.

@@ -0,0 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file might not be needed

@Martin-Molinero
Copy link
Member

Closed in favor of #47

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

Successfully merging this pull request may close these issues.

9 participants