locked
Interface error running the TwoCoins example under IronPython (Migrated from community.research.microsoft.com) RRS feed

  • Question

  • sgaffigan posted on 01-19-2011 12:24 AM

    Hello. I'm new to Infer.NET and am using it on OS X. In running the TwoCoins IronPython example I get an interface not found error (see below) during an import statement from the Distributions module (also see below). I'm running the Infer.NET 2.4 Beta 2 Release, with IronPython-2.6.2 through mono-2.8.2, on a Mac OS X 10.6.5 system.  I also tried mono-2.8.1 but the exception still occurs.

    Has anyone seen this error or have any suggestions on what might be going on?

     

    System.ArgumentException: Interface not found
    Parameter name: interfaceType
      at System.Type.GetInterfaceMap (System.Type interfaceType) [0x00000] in <filename unknown>:0 
      at IronPython.Runtime.Types.PythonType.AddSystemInterfaces (System.Collections.Generic.List`1 mro) [0x00000] in <filename unknown>:0 
      at IronPython.Runtime.Types.PythonType.AddSystemBases () [0x00000] in <filename unknown>:0 
      at IronPython.Runtime.Types.PythonType.InitializeSystemType () [0x00000] in <filename unknown>:0 
      at IronPython.Runtime.Types.PythonType..ctor (System.Type underlyingSystemType) [0x00000] in <filename unknown>:0 
      at IronPython.Runtime.Types.PythonType.GetPythonType (System.Type type) [0x00000] in <filename unknown>:0 
      at IronPython.Runtime.Types.DynamicHelpers.GetPythonTypeFromType (System.Type type) [0x00000] in <filename unknown>:0 
      at IronPython.Runtime.Operations.PythonTypeOps.GetSlot (Microsoft.Scripting.Actions.MemberGroup group, System.String name, Boolean privateBinding) [0x00000] in <filename unknown>:0 
      at IronPython.Runtime.Operations.NamespaceTrackerOps.GetCustomMember (IronPython.Runtime.CodeContext context, Microsoft.Scripting.Actions.NamespaceTracker self, System.String name) [0x00000] in <filename unknown>:0 
      at IronPython.Runtime.Operations.PythonOps.ImportStar (IronPython.Runtime.CodeContext context, System.String fullName, Int32 level) [0x00000] in <filename unknown>:0 
      at Microsoft.Scripting.Interpreter.ActionCallInstruction`3[IronPython.Runtime.CodeContext,System.String,System.Int32].Run (Microsoft.Scripting.Interpreter.InterpretedFrame frame) [0x00000] in <filename unknown>:0 
      at Microsoft.Scripting.Interpreter.Interpreter.Run (Microsoft.Scripting.Interpreter.InterpretedFrame frame) [0x00000] in <filename unknown>:0 
    Probability both coins are heads:Compiling model...done.
     Bernoulli(0.25)
    Probability distribution over firstCoin:Compiling model...done.
     Bernoulli(0.3333)
     
    
    #---------------------------------------------------------------------------
    # Infer.NET: IronPython script for two coins example
    #---------------------------------------------------------------------------
    import System,clr
    from System import *
    
    clr.AddReferenceToFile("Infer.Compiler.dll")
    clr.AddReferenceToFile("Infer.Runtime.dll")
    
    # import all namespaces
    import MicrosoftResearch.Infer
    import MicrosoftResearch.Infer.Models
    import MicrosoftResearch.Infer.Distributions
    from MicrosoftResearch.Infer import *
    from MicrosoftResearch.Infer.Models import *
    try:
      from MicrosoftResearch.Infer.Distributions import *
    except Exception, e:
      print e
    
    # The model
    firstCoin = Variable.Bernoulli(0.5)
    secondCoin = Variable.Bernoulli(0.5)
    bothHeads = firstCoin & secondCoin
    
    # The inference
    ie = InferenceEngine()
    print "Probability both coins are heads:", ie.Infer(bothHeads)
    bothHeads.ObservedValue = False
    print "Probability distribution over firstCoin:", ie.Infer(firstCoin)
    

     

    Thanks for your help

    Friday, June 3, 2011 6:16 PM

Answers

  • John Guiver replied on 01-20-2011 6:03 AM

    I get a similar though less informative error running Mono on Windows:

    C:\Program Files\IronPython 2.6>mono ipy.exe IronPythonTwoCoins.py

    Traceback (most recent call last):
      File "IronPythonTwoCoins.py", line 19, in <module>
    ValueError: Interface not found
    Parameter name: interfaceTyp

    Including the verbose option provides a lot more output but no more insight (at least to my eyes).

    When we put out a release, we do independent tests for IronPython running natively, and for Mono (Windows) using the mcs compiler on C# examples - these tests pass. So it looks like it is the combination of Iron Python, Mono, and Infer.NET that is the problem. Do you have a history of running IronPython under Mono? If so, have you successfully used other application libraries?

    I cannot see anything special about the modules you mention. You can take a look at the source for these which is part of the release (they sit in the Source\Distributions folder under the install folder).

    Although we don't support running under Mono other than running the test mentioned above, any insight that you or the community can give on this would be greatly appreciated.

    John

    Friday, June 3, 2011 6:16 PM

All replies

  • John Guiver replied on 01-19-2011 3:51 AM

    Hi

    Can you give details of the command you ran to build and run this under Mono? I can then at least test it on the Windows version of Mono. Unfortunately we don't have ready capability to test this on OS X.

    By the way - I see that the example does run correctly - i.e. you do get the two posterior distributions output from the program.

    John

    Friday, June 3, 2011 6:16 PM
  • sgaffigan replied on 01-19-2011 10:50 AM

    John,

    Thanks for the response.  It's already helpful to know that Mono is your first suspect.  Note, any of the following modules from Distributions, none of which are needed in the example, produce the error during import.

    DiscreteEnum
    DistributionRefArray
    DistributionRefArray2D
    DistributionStructArray
    DistributionStructArray2D
    Mixture
    PointMass
    

    I built Mono 2.8.1 as follows:

    ./configure --prefix=$HOME/local/mono-2.8.1 --with-glib=embedded --enable-nls=no
    make
    make install
    

    The config output is below:

        mcs source:  mcs
        olive source: 
    
      Engine:
        GC:      sgen and bundled Boehm GC with typed GC
        GLIB:     embedded
        TLS:      pthread
        SIGALTSTACK:  no
        Engine:    Building and using the JIT
        oprofile:   no
        BigArrays:   no
        DTrace:    yes
        Parallel Mark: Disabled_Currently_Hangs_On_MacOSX
        LLVM Back End: no (dynamically loaded: no)
    
      Libraries:
        Moon Profile: no
        MonoTouch:   no
        JNI support:  IKVM Native
        libgdiplus:  assumed to be installed
        zlib:     bundled zlib
    

    The command I use to run the example is:

    cd $HOME/local/InferNet2.4/bin/Release
    $HOME/local/mono-2.8.1/bin/mono $HOME/local/IronPython-2.6.2/ipy.exe twocoins.py
    

     

    Thanks again.

    Friday, June 3, 2011 6:16 PM
  • John Guiver replied on 01-20-2011 6:03 AM

    I get a similar though less informative error running Mono on Windows:

    C:\Program Files\IronPython 2.6>mono ipy.exe IronPythonTwoCoins.py

    Traceback (most recent call last):
      File "IronPythonTwoCoins.py", line 19, in <module>
    ValueError: Interface not found
    Parameter name: interfaceTyp

    Including the verbose option provides a lot more output but no more insight (at least to my eyes).

    When we put out a release, we do independent tests for IronPython running natively, and for Mono (Windows) using the mcs compiler on C# examples - these tests pass. So it looks like it is the combination of Iron Python, Mono, and Infer.NET that is the problem. Do you have a history of running IronPython under Mono? If so, have you successfully used other application libraries?

    I cannot see anything special about the modules you mention. You can take a look at the source for these which is part of the release (they sit in the Source\Distributions folder under the install folder).

    Although we don't support running under Mono other than running the test mentioned above, any insight that you or the community can give on this would be greatly appreciated.

    John

    Friday, June 3, 2011 6:16 PM