Menu

Running DWSIM in Docker

G C
2022-01-07
2022-01-11
  • G C

    G C - 2022-01-07

    Hello,
    I'm trying to build a Linux Docker container so as to be able to automate runs for parametric analysis, e.g., figure out how certain simulation outputs change based on changes on inputs. I don't want to run the UI - I just want to run it in headless mode.

    Below is the Dockerfile I used to create the Docker image. It has...
    Ubuntu 20.04 as a base
    Python version: 3.8.10
    Mono version: 6.12.0.122
    DWSIM version: 7.1.2
    pythonnet version: 2.5.2

    FROM ubuntu:20.04
    
    RUN apt update
    RUN apt upgrade -y
    
    # Set timezone variables for tzdata
    ENV TZ=Asia/Kolkata
    RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
    
    # Install python, pip, vi and wget
    RUN apt install -y vim python3 python3-pip wget
    
    # Install mono based on https://www.mono-project.com/download/stable/#download-lin
    RUN apt install -y gnupg ca-certificates
    RUN apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF
    RUN echo "deb https://download.mono-project.com/repo/ubuntu stable-focal main" | tee /etc/apt/sources.list.d/mono-official-stable.list
    RUN apt update
    RUN apt install -y mono-complete
    
    # Install pythonnet
    RUN pip install pythonnet
    
    # Download and install DWSIM
    RUN wget https://downloads.sourceforge.net/project/dwsim/DWSIM/DWSIM%207.1/7.1.2/dwsim_7.1.2-amd64.deb
    RUN apt install -y ./dwsim_7.1.2-amd64.deb
    

    Within the running container, I use this python file to try and create a flowsheet. It is based on the sample code in section 34.5.5 of the user guide - but it does not have the pythoncom import because I can't install pywin32 on linux.

    import clr
    
    dwsimpath='/usr/local/lib/dwsim/'
    
    from System import String, Environment
    from System.IO import Directory, Path, File
    
    clr.AddReference(dwsimpath+'DWSIM.Automation.dll')
    clr.AddReference(dwsimpath+'DWSIM.Interfaces.dll')
    clr.AddReference(dwsimpath+'DWSIM.GlobalSettings.dll')
    clr.AddReference(dwsimpath+'DWSIM.SharedClasses.dll')
    clr.AddReference(dwsimpath+'DWSIM.Thermodynamics.dll')
    clr.AddReference(dwsimpath+'DWSIM.UnitOperations.dll')
    clr.AddReference(dwsimpath+'DWSIM.Inspector.dll')
    clr.AddReference(dwsimpath+'DWSIM.MathOps.dll')
    clr.AddReference(dwsimpath+'TcpComm.dll')
    clr.AddReference(dwsimpath+'Microsoft.ServiceBus.dll')
    
    from DWSIM.Automation import Automation2
    from DWSIM.Interfaces.Enums.GraphicObjects import ObjectType
    from DWSIM.GlobalSettings import Settings
    
    Directory.SetCurrentDirectory(dwsimpath)
    
    interf = Automation2()
    sim = interf.CreateFlowsheet()
    

    When I try and run this file though, it crashes when the Automation2 object is being initialised:

    Initializing DWSIM Automation Interface...
    * Assertion at assembly.c:1939, condition `is_ok (hook_error)' not met, function:mono_assembly_invoke_load_hook_internal, (null) assembly:/usr/lib/mono/4.5/mscorlib.dll type:ReflectionTypeLoadException member:(null)
    
    
    =================================================================
        Native Crash Reporting
    =================================================================
    Got a SIGABRT while executing native code. This usually indicates
    a fatal error in the mono runtime or one of the native libraries 
    used by your application.
    =================================================================
    
    =================================================================
        Native stacktrace:
    =================================================================
        0x7f63571ab13b - /lib/libmonosgen-2.0.so.1 : 
        0x7f63571ab4cd - /lib/libmonosgen-2.0.so.1 : 
        0x7f63571363c7 - /lib/libmonosgen-2.0.so.1 : 
        0x7f63571aa6bc - /lib/libmonosgen-2.0.so.1 : 
        0x7f635790b210 - /lib/x86_64-linux-gnu/libc.so.6 : 
        0x7f635790b18b - /lib/x86_64-linux-gnu/libc.so.6 : gsignal
        0x7f63578ea859 - /lib/x86_64-linux-gnu/libc.so.6 : abort
        0x7f6357098384 - /lib/libmonosgen-2.0.so.1 : 
        0x7f635737f4e5 - /lib/libmonosgen-2.0.so.1 : 
        0x7f635739a8ae - /lib/libmonosgen-2.0.so.1 : 
        0x7f635739af63 - /lib/libmonosgen-2.0.so.1 : monoeg_assertion_message
        0x7f63572182e3 - /lib/libmonosgen-2.0.so.1 : 
        0x7f6357219176 - /lib/libmonosgen-2.0.so.1 : 
        0x7f635721b343 - /lib/libmonosgen-2.0.so.1 : 
        0x7f635720b2d5 - /lib/libmonosgen-2.0.so.1 : 
        0x7f635720b3cf - /lib/libmonosgen-2.0.so.1 : 
        0x7f635720d075 - /lib/libmonosgen-2.0.so.1 : 
        0x7f63572158b1 - /lib/libmonosgen-2.0.so.1 : 
        0x7f635721a5ed - /lib/libmonosgen-2.0.so.1 : 
        0x7f635721c00d - /lib/libmonosgen-2.0.so.1 : 
        0x7f635721ce29 - /lib/libmonosgen-2.0.so.1 : mono_assembly_load_reference
        0x7f6357224dfb - /lib/libmonosgen-2.0.so.1 : mono_class_from_typeref_checked
        0x7f63572250d5 - /lib/libmonosgen-2.0.so.1 : mono_class_get_checked
        0x7f635722a0bd - /lib/libmonosgen-2.0.so.1 : 
        0x7f6357225105 - /lib/libmonosgen-2.0.so.1 : mono_class_get_checked
        0x7f635724a17d - /lib/libmonosgen-2.0.so.1 : 
        0x7f635724a307 - /lib/libmonosgen-2.0.so.1 : 
        0x7f6357261c1c - /lib/libmonosgen-2.0.so.1 : 
        0x403fd468 - Unknown
    
    =================================================================
        Telemetry Dumper:
    =================================================================
    Pkilling 0x140064592635648x from 0x140064645420864x
    Entering thread summarizer pause from 0x140064645420864x
    Finished thread summarizer pause from 0x140064645420864x.
    Aborted
    

    I've tried to run a couple of troubleshooting tests as specified on a couple of the other topics but I'm not familiar with mono or C# so I don't know if I'm doing them right. I'm not sure if I'm missing a package or whether there's some sort of incompatibility between the software versions I'm using. Any thoughts on what's going wrong? Any help would be greatly appreciated.

    Thanks!

     
  • G C

    G C - 2022-01-07

    I also tried the test file located here (with a minor modification for the path of the file to be loaded): https://github.com/DanWBR/DWSIM.Automation.Test.macOS/blob/master/DWSIM.Automation.Test.macOS/Program.cs
    within the container. This did initialize the automation interface, but then gave a whole bunch of other errors:

    Initializing DWSIM Automation Interface...
    DWSIM Automation Interface initialized successfully.
    Filepath: /usr/local/lib/dwsim/test.dwxmz
    Initializing the Flowsheet, please wait...
    
    (test_dwsim:102): GLib-GObject-WARNING **: 19:10:04.185: invalid (NULL) pointer instance
    
    (test_dwsim:102): GLib-GObject-CRITICAL **: 19:10:04.185: g_signal_connect_data: assertion 'G_TYPE_CHECK_INSTANCE (instance)' failed
    
    (test_dwsim:102): Gdk-CRITICAL **: 19:10:06.335: IA__gdk_pango_context_get_for_screen: assertion 'GDK_IS_SCREEN (screen)' failed
    
    (test_dwsim:102): Pango-CRITICAL **: 19:10:06.335: pango_context_set_font_description: assertion 'context != NULL' failed
    
    (test_dwsim:102): Pango-CRITICAL **: 19:10:06.335: pango_context_set_base_dir: assertion 'context != NULL' failed
    
    (test_dwsim:102): Pango-CRITICAL **: 19:10:06.335: pango_context_set_language: assertion 'context != NULL' failed
    
    (test_dwsim:102): Pango-CRITICAL **: 19:10:06.335: pango_layout_new: assertion 'context != NULL' failed
    
    (test_dwsim:102): Pango-CRITICAL **: 19:10:06.335: pango_layout_set_attributes: assertion 'layout != NULL' failed
    
    (test_dwsim:102): Pango-CRITICAL **: 19:10:06.335: pango_layout_set_text: assertion 'layout != NULL' failed
    
    (test_dwsim:102): Pango-CRITICAL **: 19:10:06.335: pango_layout_get_unknown_glyphs_count: assertion 'PANGO_IS_LAYOUT (layout)' failed
    
    (test_dwsim:102): GLib-GObject-CRITICAL **: 19:10:06.335: g_object_unref: assertion 'G_IS_OBJECT (object)' failed
    
    (test_dwsim:102): Gdk-CRITICAL **: 19:10:06.338: IA__gdk_pango_context_get_for_screen: assertion 'GDK_IS_SCREEN (screen)' failed
    
    (test_dwsim:102): Pango-CRITICAL **: 19:10:06.338: pango_context_set_font_description: assertion 'context != NULL' failed
    
    (test_dwsim:102): Pango-CRITICAL **: 19:10:06.338: pango_context_set_base_dir: assertion 'context != NULL' failed
    
    (test_dwsim:102): Pango-CRITICAL **: 19:10:06.338: pango_context_set_language: assertion 'context != NULL' failed
    
    (test_dwsim:102): Pango-CRITICAL **: 19:10:06.338: pango_layout_new: assertion 'context != NULL' failed
    
    (test_dwsim:102): Pango-CRITICAL **: 19:10:06.338: pango_layout_set_attributes: assertion 'layout != NULL' failed
    
    (test_dwsim:102): Pango-CRITICAL **: 19:10:06.338: pango_layout_set_text: assertion 'layout != NULL' failed
    
    (test_dwsim:102): Pango-CRITICAL **: 19:10:06.338: pango_layout_get_unknown_glyphs_count: assertion 'PANGO_IS_LAYOUT (layout)' failed
    
    (test_dwsim:102): GLib-GObject-CRITICAL **: 19:10:06.338: g_object_unref: assertion 'G_IS_OBJECT (object)' failed
    
    (test_dwsim:102): Gdk-CRITICAL **: 19:10:06.338: IA__gdk_pango_context_get_for_screen: assertion 'GDK_IS_SCREEN (screen)' failed
    
    (test_dwsim:102): Pango-CRITICAL **: 19:10:06.338: pango_context_set_font_description: assertion 'context != NULL' failed
    
    (test_dwsim:102): Pango-CRITICAL **: 19:10:06.338: pango_context_set_base_dir: assertion 'context != NULL' failed
    
    (test_dwsim:102): Pango-CRITICAL **: 19:10:06.338: pango_context_set_language: assertion 'context != NULL' failed
    
    (test_dwsim:102): Pango-CRITICAL **: 19:10:06.338: pango_layout_new: assertion 'context != NULL' failed
    
    (test_dwsim:102): Pango-CRITICAL **: 19:10:06.339: pango_layout_set_attributes: assertion 'layout != NULL' failed
    
    (test_dwsim:102): Pango-CRITICAL **: 19:10:06.339: pango_layout_set_text: assertion 'layout != NULL' failed
    
    (test_dwsim:102): Pango-CRITICAL **: 19:10:06.339: pango_layout_get_unknown_glyphs_count: assertion 'PANGO_IS_LAYOUT (layout)' failed
    
    (test_dwsim:102): GLib-GObject-CRITICAL **: 19:10:06.339: g_object_unref: assertion 'G_IS_OBJECT (object)' failed
    
    (test_dwsim:102): GLib-GObject-WARNING **: 19:10:06.343: invalid (NULL) pointer instance
    
    (test_dwsim:102): GLib-GObject-CRITICAL **: 19:10:06.343: g_signal_connect_data: assertion 'G_TYPE_CHECK_INSTANCE (instance)' failed
    
    (test_dwsim:102): Gdk-CRITICAL **: 19:10:06.455: IA__gdk_pango_context_get_for_screen: assertion 'GDK_IS_SCREEN (screen)' failed
    
    (test_dwsim:102): Pango-CRITICAL **: 19:10:06.455: pango_context_set_font_description: assertion 'context != NULL' failed
    
    (test_dwsim:102): Pango-CRITICAL **: 19:10:06.455: pango_context_set_base_dir: assertion 'context != NULL' failed
    
    (test_dwsim:102): Pango-CRITICAL **: 19:10:06.455: pango_context_set_language: assertion 'context != NULL' failed
    
    (test_dwsim:102): Pango-CRITICAL **: 19:10:06.455: pango_layout_new: assertion 'context != NULL' failed
    
    (test_dwsim:102): Pango-CRITICAL **: 19:10:06.455: pango_layout_set_attributes: assertion 'layout != NULL' failed
    
    (test_dwsim:102): Pango-CRITICAL **: 19:10:06.455: pango_layout_set_text: assertion 'layout != NULL' failed
    
    (test_dwsim:102): Pango-CRITICAL **: 19:10:06.456: pango_layout_get_unknown_glyphs_count: assertion 'PANGO_IS_LAYOUT (layout)' failed
    
    (test_dwsim:102): GLib-GObject-CRITICAL **: 19:10:06.456: g_object_unref: assertion 'G_IS_OBJECT (object)' failed
    
    (test_dwsim:102): GLib-GObject-WARNING **: 19:10:06.459: invalid (NULL) pointer instance
    
    (test_dwsim:102): GLib-GObject-CRITICAL **: 19:10:06.459: g_signal_connect_data: assertion 'G_TYPE_CHECK_INSTANCE (instance)' failed
    
    (test_dwsim:102): Gdk-CRITICAL **: 19:10:06.501: IA__gdk_pango_context_get_for_screen: assertion 'GDK_IS_SCREEN (screen)' failed
    
    (test_dwsim:102): Pango-CRITICAL **: 19:10:06.501: pango_context_set_font_description: assertion 'context != NULL' failed
    
    (test_dwsim:102): Pango-CRITICAL **: 19:10:06.501: pango_context_set_base_dir: assertion 'context != NULL' failed
    
    (test_dwsim:102): Pango-CRITICAL **: 19:10:06.501: pango_context_set_language: assertion 'context != NULL' failed
    
    Unhandled Exception:
    System.TypeInitializationException: The type initializer for 'DWSIM.CrossPlatform.UI.Controls.ReoGrid.Rendering.StaticResources' threw an exception. ---> System.NullReferenceException: Object reference not set to an instance of an object
      at Eto.GtkSharp.Drawing.FontFamilyHandler.GetFontFamily (System.String familyName) [0x00021] in <2084ba8256c9420ea60ad1e5f1df14e5>:0 
      at Eto.GtkSharp.Drawing.FontFamilyHandler.FindCorrectedFamily (System.String familyName) [0x00000] in <2084ba8256c9420ea60ad1e5f1df14e5>:0 
      at Eto.GtkSharp.Drawing.FontFamilyHandler.Create (System.String familyName) [0x00185] in <2084ba8256c9420ea60ad1e5f1df14e5>:0 
      at Eto.Drawing.FontFamily..ctor (System.String familyName) [0x0001f] in <23bf6400f02d49eba883a8238fbdb959>:0 
      at Eto.GtkSharp.Drawing.FontHandler.get_Family () [0x00024] in <2084ba8256c9420ea60ad1e5f1df14e5>:0 
      at Eto.GtkSharp.Drawing.FontHandler.get_FamilyName () [0x0000a] in <2084ba8256c9420ea60ad1e5f1df14e5>:0 
      at Eto.Drawing.Font.get_FamilyName () [0x00006] in <23bf6400f02d49eba883a8238fbdb959>:0 
      at DWSIM.CrossPlatform.UI.Controls.ReoGrid.Rendering.StaticResources..cctor () [0x0000f] in <cffad92066e242f68dd8dda3110d915e>:0 
       --- End of inner exception stack trace ---
      at DWSIM.CrossPlatform.UI.Controls.ReoGrid.ReoGridControl.InitControl () [0x00001] in <cffad92066e242f68dd8dda3110d915e>:0 
      at DWSIM.CrossPlatform.UI.Controls.ReoGrid.ReoGridControl..ctor (Eto.Forms.PixelLayout pixparent) [0x000e5] in <cffad92066e242f68dd8dda3110d915e>:0 
      at DWSIM.CrossPlatform.UI.Controls.ReoGrid.ReoGridFullControl..ctor (System.Boolean automationmode) [0x00015] in <cffad92066e242f68dd8dda3110d915e>:0 
      at DWSIM.UI.Desktop.Editors.Spreadsheet..ctor (DWSIM.UI.Desktop.Shared.Flowsheet fs) [0x0012e] in <71e7cdd296c1459eb8668560760c06fc>:0 
      at DWSIM.UI.Forms.Flowsheet.InitializeComponent () [0x001d7] in <54314724463e4b4f937554a6e7126bb4>:0 
      at DWSIM.UI.Forms.Flowsheet..ctor () [0x00058] in <54314724463e4b4f937554a6e7126bb4>:0 
      at DWSIM.Automation.Automation2.LoadFlowsheet (System.String filepath) [0x00010] in <5eb619eed768455fb2b6fd18c3c33588>:0 
      at DWSIM.Automation.Test.macOS.Program.Main () [0x00043] in <dceab73bed214375afab5a0a474ec0cd>:0 
    [ERROR] FATAL UNHANDLED EXCEPTION: System.TypeInitializationException: The type initializer for 'DWSIM.CrossPlatform.UI.Controls.ReoGrid.Rendering.StaticResources' threw an exception. ---> System.NullReferenceException: Object reference not set to an instance of an object
      at Eto.GtkSharp.Drawing.FontFamilyHandler.GetFontFamily (System.String familyName) [0x00021] in <2084ba8256c9420ea60ad1e5f1df14e5>:0 
      at Eto.GtkSharp.Drawing.FontFamilyHandler.FindCorrectedFamily (System.String familyName) [0x00000] in <2084ba8256c9420ea60ad1e5f1df14e5>:0 
      at Eto.GtkSharp.Drawing.FontFamilyHandler.Create (System.String familyName) [0x00185] in <2084ba8256c9420ea60ad1e5f1df14e5>:0 
      at Eto.Drawing.FontFamily..ctor (System.String familyName) [0x0001f] in <23bf6400f02d49eba883a8238fbdb959>:0 
      at Eto.GtkSharp.Drawing.FontHandler.get_Family () [0x00024] in <2084ba8256c9420ea60ad1e5f1df14e5>:0 
      at Eto.GtkSharp.Drawing.FontHandler.get_FamilyName () [0x0000a] in <2084ba8256c9420ea60ad1e5f1df14e5>:0 
      at Eto.Drawing.Font.get_FamilyName () [0x00006] in <23bf6400f02d49eba883a8238fbdb959>:0 
      at DWSIM.CrossPlatform.UI.Controls.ReoGrid.Rendering.StaticResources..cctor () [0x0000f] in <cffad92066e242f68dd8dda3110d915e>:0 
       --- End of inner exception stack trace ---
      at DWSIM.CrossPlatform.UI.Controls.ReoGrid.ReoGridControl.InitControl () [0x00001] in <cffad92066e242f68dd8dda3110d915e>:0 
      at DWSIM.CrossPlatform.UI.Controls.ReoGrid.ReoGridControl..ctor (Eto.Forms.PixelLayout pixparent) [0x000e5] in <cffad92066e242f68dd8dda3110d915e>:0 
      at DWSIM.CrossPlatform.UI.Controls.ReoGrid.ReoGridFullControl..ctor (System.Boolean automationmode) [0x00015] in <cffad92066e242f68dd8dda3110d915e>:0 
      at DWSIM.UI.Desktop.Editors.Spreadsheet..ctor (DWSIM.UI.Desktop.Shared.Flowsheet fs) [0x0012e] in <71e7cdd296c1459eb8668560760c06fc>:0 
      at DWSIM.UI.Forms.Flowsheet.InitializeComponent () [0x001d7] in <54314724463e4b4f937554a6e7126bb4>:0 
      at DWSIM.UI.Forms.Flowsheet..ctor () [0x00058] in <54314724463e4b4f937554a6e7126bb4>:0 
      at DWSIM.Automation.Automation2.LoadFlowsheet (System.String filepath) [0x00010] in <5eb619eed768455fb2b6fd18c3c33588>:0 
      at DWSIM.Automation.Test.macOS.Program.Main () [0x00043] in <dceab73bed214375afab5a0a474ec0cd>:0 
    
     

Log in to post a comment.