Code Monkey home page Code Monkey logo

.net-bridge's People

Contributors

daveyboy103 avatar jar1karp avatar tr8dr avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

.net-bridge's Issues

Valued returned by reference

Will it be possible to access results returned as a reference in the function call argument, like here:
MathNet.Numerics.Distributions.Normal.Samples(System.Double[],System.Double,System.Double)

        <summary>
        Fills an array with samples generated from the distribution.
        </summary>
        <param name="values">The array to fill with the samples.</param>
        <param name="mean">The mean (μ) of the normal distribution.</param>
        <param name="stddev">The standard deviation (σ) of the normal distribution. Range: σ ≥ 0.</param>
        <returns>a sequence of samples from the distribution.</returns>
    </member>

Access constants of a static class

Is there a way to access constants of a static class? The code would look like

namespace MyNamespace
{
public static class MyConstants
{
public const int CONST_1 = 38;
public const int CONST_2 = 20;
public const int CONST_3 = 100;
...

CRAN R package is v0.9.1, but multiple DLLs only available in v0.9.2

The version of rDotNet in CRAN is 0.9.1, but unfortunately that version does not handle multiple DLLs in the .cinit...() function (interestingly, the CLRServer in that package DOES handle multiple DLLs).

The github project is up to 0.9.2 and the commit message states that the .cinit function has been extended to handle multiple DLLs ("adjusted rDotNet cinit function to accept multiple dlls")

Is there any chance of publishing version 0.9.2 of rDotNet to CRAN?

Thanks,
Andrew

Cannot load class from dll

I have installed the package and dependencies and am attempting to import a custom DLL however I get the following error when attempting to import it.
I would like to know if I am doing something wrong or if this is a known bug.

Traceback (most recent call last):
  File ".\test.py", line 10, in <module>
    printer = clr.new("Printer.Printer")
  File "D:\test\.Net-Bridge\venv\lib\site-packages\pydotnet\clr\CLRApi.py", line 123, in new
    return rep.toValue()
  File "D:\test\.Net-Bridge\venv\lib\site-packages\pydotnet\clr\data\CLRException.py", line 56, in toValue
    raise Exception (self.value)
Exception: System.ArgumentException: could not find type: Printer.Printer
   ? bridge.common.reflection.Creator.NewInstanceByName(String typename, Object[] args) dans d:\test\.Net-Bridge\src\Python\pyDotNet\server\Library.cs:ligne 16939
   ? bridge.embedded.CLRBridgeEmbedded.Create(String classname, Object[] parameters) dans d:\test\.Net-Bridge\src\Python\pyDotNet\server\Library.cs:ligne 84
   ? bridge.server.CLRBridgeServerClient.HandleCreate(CLRCreateMessage req) dans d:\test\.Net-Bridge\src\Python\pyDotNet\server\Library.cs:ligne 1057
WARN  [2020-05-29 09:36:27.904]: receipt of messsage failed: System.IO.EndOfStreamException: End of stream reached with 1 byte left to read
   à bridge.common.io.SameEndianReader.InternalReadByte() dans d:\test\.Net-Bridge\src\Python\pyDotNet\server\Library.cs:ligne 10400
   à bridge.common.io.SameEndianReader.ReadUInt16() dans d:\test\.Net-Bridge\src\Python\pyDotNet\server\Library.cs:ligne 10221
   à bridge.server.CLRMessage.Read(IBinaryReader stream) dans d:\test\.Net-Bridge\src\Python\pyDotNet\server\Library.cs:ligne 1422
   à bridge.server.CLRBridgeServerClient.Service() dans d:\test\.Net-Bridge\src\Python\pyDotNet\server\Library.cs:ligne 980, stack:    à bridge.common.io.SameEndianReader.InternalReadByte() dans d:\test\.Net-Bridge\src\Python\pyDotNet\server\Library.cs:ligne 10400
   à bridge.common.io.SameEndianReader.ReadUInt16() dans d:\test\.Net-Bridge\src\Python\pyDotNet\server\Library.cs:ligne 10221
   à bridge.server.CLRMessage.Read(IBinaryReader stream) dans d:\test\.Net-Bridge\src\Python\pyDotNet\server\Library.cs:ligne 1422
   à bridge.server.CLRBridgeServerClient.Service() dans d:\test\.Net-Bridge\src\Python\pyDotNet\server\Library.cs:ligne 980

Here is the C# file used to generate the dll

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Printer
{
    public class Printer
    {
        public void Print(string text)
        {
            Console.WriteLine(text);
        }
    }
}

And here is the python code I am using to import it

import os
virtual_env = os.environ['VIRTUAL_ENV']

print(f"Venv:{virtual_env}")

from pydotnet.clr.CLRApi import CLRApi

clr = CLRApi(hostname="localhost", dll="Printer.dll")

printer = clr.new("Printer.Printer")
printer.Print("HelloWorld!")

Given that I am using a virtualenv I also had to modifiy CLRApi.py l.77 like so
server = "%s/Lib/site-packages/pydotnet/server/CLRServer.exe" % os.environ["VIRTUAL_ENV"]

I am on Windows 10 using python3.6.8

This is the dll file generated
Printer.zip

guidance on starting/stopping CLRserver and using .Net-bridge in a package

First, thank you for a developing this awesome solution for accessing .NET from R and Python.

I'm looking for documentation or best practices guidance on using RDotNet and the .Net-Bridge in an R package. My current strategy is to use .cinit in the .onLoad() namespace hook to spin up the CLRServer and load the necessary DLL (recognizing that this could cause conflicts with other packages that also use CLRServer, but the solution to #4 would resolve that). What's not clear to me is what I should do when the R session is closed or the package is unloaded. Is there a command to quit the server? Is there any cleanup I need to do to delete objects created by .cnew? Some additional guidance documents would be helpful.

Run multiple threads of RScript.exe loading different dlls via CLRServer.exe

Hi Jonathan,

I have a further question regarding the rDotNet package:

Currently one can only load one dll and R has to be restarted if another dll has to be loaded. The ref-manual states:

the .NET libraries are to be changed, the CLRServer process and R should be restarted.

This behavior in some situations can have some tricky side-effects. For example (to the best of my knowledge) it is not possible to parallely run two R-Scripts (via RScript.exe) where one R-Script has to load and use a.dll and the other process b.dll.

To be honest, I'm not an expert in .NET at all, but would it be possible to change CLRServer.exe in a way, that each R-Thread can assemble an own and independent connection to the server. (Like the DBI package for databases, where it is possible to independently connect to the database (if that is a good example))

Thanks and Cheers
Simon

_cache_io dictionary gets corrupted

Sometimes the internal cache dictionaries for ObjectId and objects gets corrupted and the program tries to access a key that does not exist. Currently only fixable by restarting the server.

CLRObjectProxy.cs

.cinit only supports one dll

Hi,
currently one can only specify one dll-file in the .cinit function of the rDotNet package. This could easily be fixed by changing the internal .initialize function of the rDotNet package.

First besides the inside functions expand.dll and or one had to specify a further function as:

enlarge.dll <- function(dll) {
	server.args <- rep(NA, length(dll) * 2)
	for (i in 1:length(server.args)) {
		if (i%%2 == 1) {
			server.args[i] <- "-dll" 
		} else {
			server.args[i] <- dll[[i/2]]
		}
	}
	return(server.args)
}

And change the part where the arguments are sent to CLRServer.exe

if (!is.null(dll))
   server.args <- c(server.args, "-dll", enlarge.dll(expand.dll(dll)))
else if (dll.env != "")
   server.args <- c(server.args, "-dll", expand.dll(dll.env))

Best Simon

Import Error in Python 3.10

For compatibility with Python 3.10 the import for DataUtil.py need to change:

import numpy as np

import pandas as pd

try:
    
    from collections.abc import Iterable

except ImportError:
    
    from collections import Iterable

from scipy.stats import *

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.