Setting Up your Notebook

Create a new Polyglot Notebook using the command "Polyglot Notebook: Create new blank notebook". You can access this command by pressing Ctrl+Shift+P on Windows or Cmd+Shift+P on Mac. Then type any part of the command name, such as "notebook".

Select the ".ipynb" file format, and "C#" as the default language.

Your notebook starts with a C# code block. Enter the following references to bring in Jinaga and some modeling tools:

// Reference the Jinaga NuGet packages
#r "nuget: Jinaga, 1.0.0"
#r "nuget: Jinaga.Notebooks, 1.0.0"
#r "nuget: Jinaga.UnitTest, 1.0.0"

Then click the run button next to the code block to execute it. The packages will be downloaded and installed.

Create a new code block by moving your mouse just below the first code block near the center of the page. Inside of this code block, reference the namespaces.

using Jinaga;
using Jinaga.Notebooks;
using Jinaga.UnitTest;

Save this first notebook in a folder called 0-setup. Name the notebook Packages.ipynb. This structure will make it easier to organize your thoughts and keep like notebooks together.

Jinaga Client

The second notebook you'll want to create will initialize a new Jinaga client. Create a new notebook as before (.ipynb and C#). Then begin with the first code block.

#!import "../0-setup/Packages.ipynb"

Save this notebook in the 0-setup file and name it Client.ipynb. Then you can run this first cell. it should import the previous notebook and load the packages.

Even though this second notebook is in the same folder as the first, we use the folder name in the relative path. This ensures that the import can be resolved even when the current directory is a different folder.

Now create a second cell and initialize a Jinaga client.

// Create a Jinaga client for unit testing
var jinagaClient = JinagaTest.Create(opt =>
{
    // Simulate a logged in user
    opt.User = new User("--- FAKE USER ---");
});

With this, you can begin your modeling session.

Notebook Tips

The Polyglot Notebook can get into strange states, especially as you modify types. If you find that the notebook is not behaving as you expect, you can restart the kernel. Click the "Clear All Outputs" button and then the "Restart" button in the toolbar at the top of the page.

Restart and Clear All Outputs

Notebook Structure

Create a new notebook in a 1-models folder at the same level as 0-setup. In the first cell of this notebook, import the Packages notebook.

#!import "../0-setup/Packages.ipynb"

This is where you will define your fact types and render fact type graphs.

The next folder -- 2-scenarios -- is for declaring instances. Notebooks at this layer import models and the Jinaga client.

#!import "../1-models/YourModel.ipynb"
#!import "../0-setup/Client.ipynb"

Now you can create instances of facts, render fact instance diagrams, and run specifications.

The last folder is 3-operations. This is for operational runbooks. Instead of importing the test Jinaga client from Client.ipynb, these notebooks will import a shared Connection.ipynb that connects to an actual environment. Details on that notebook will follow.

To summarize, your structure will look like this:

  • 0-setup
    • Packages.ipynb
    • Client.ipynb
  • 1-models
    • ModelA.ipynb
    • ModelB.ipynb
    • IntegrationAtoB.ipynb
  • 2-scenarios
    • ScenarioA.ipynb
    • ScenarioB.ipynb
  • 3-operations
    • Connection.ipynb
    • RunbookA.ipynb
    • RunbookB.ipynb

Connect the notebooks like this:

Imports between notebooks cluster_0 0-setup cluster_1 1-models cluster_3 3-operations cluster_2 2-scenarios Client Client Packages Packages Client->Packages ModelA ModelA ModelA->Packages ModelB ModelB ModelB->Packages IntegrationAtoB IntegrationAtoB IntegrationAtoB->ModelA IntegrationAtoB->ModelB ScenarioA ScenarioA ScenarioA->Client ScenarioA->ModelA ScenarioB ScenarioB ScenarioB->Client ScenarioB->ModelB RunbookA RunbookA RunbookA->ModelA Connection Connection RunbookA->Connection RunbookB RunbookB RunbookB->ModelB RunbookB->Connection

Continue With

Top-Level Facts

Jinaga is a product of Jinaga LLC.

Michael L Perry, President