Microsoft.SmartPlaces.Facilities.IngestionManager 0.4.2-preview

Prefix Reserved
This is a prerelease version of Microsoft.SmartPlaces.Facilities.IngestionManager.
There is a newer prerelease version of this package available.
See the version list below for details.
dotnet add package Microsoft.SmartPlaces.Facilities.IngestionManager --version 0.4.2-preview                
NuGet\Install-Package Microsoft.SmartPlaces.Facilities.IngestionManager -Version 0.4.2-preview                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Microsoft.SmartPlaces.Facilities.IngestionManager" Version="0.4.2-preview" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Microsoft.SmartPlaces.Facilities.IngestionManager --version 0.4.2-preview                
#r "nuget: Microsoft.SmartPlaces.Facilities.IngestionManager, 0.4.2-preview"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Microsoft.SmartPlaces.Facilities.IngestionManager as a Cake Addin
#addin nuget:?package=Microsoft.SmartPlaces.Facilities.IngestionManager&version=0.4.2-preview&prerelease

// Install Microsoft.SmartPlaces.Facilities.IngestionManager as a Cake Tool
#tool nuget:?package=Microsoft.SmartPlaces.Facilities.IngestionManager&version=0.4.2-preview&prerelease                

IngestionManager

This library, intended to work in conjunction with and depending on the Microsoft.SmartPlaces.Facilities.OntologyMapper library, provides interfaces and a partial implementation for ingesting existing building data graphs into Azure Digital Twins, populating the latter with twins and relationships sourced from the former.

How to use

In order to use this library, you need to create at minimum two classes:

  • A subclass of IngestionProcessorBase (implementing IGraphIngestionProcessor)
  • An implementation of IInputGraphManager

The IngestionProcessorBase subclass must provide an implementation of the abstract method ProcessSites(). That method should initiate ingestion of all sites (e.g., campuses/buildings or other suitable starting nodes) from the input graph, traverse them and their child nodes (buildings, floors, rooms, etc), translating them as necessary, and storing them in the output Azure Digital Twins graph.

In order to aid in this process, the IngestionProcessorBase class references implementations of IInputGraphManager and IOutputGraphManager that you may use to interact with the input and output graphs, respectively. An Azure Digital Twins-specific implementation of the latter is provided for you in AzureDigitalTwinsGraphManager, but you will need to create the former, adapted to whatever data source you are ingesting from.

Additionally, in order to reconcile any ontological differences between source and target graph, the IngestionProcessorBase provides convenience methods for mapping terms from the input to terms in the output (e.g., DTDL Interfaces, Relationships, etc.). These methods require that an implementation of IOntologyMappingManager from the aforementioned OntologyMapper library, loaded with a set of mappings between the used ontologies, be passed into to the IngestionProcessorBase constructor.

Example

For an example of an implementation using this library, including the creation of those above-mentioned required implementations, see the Microsoft.SmartPlaces.Facilities.IngestionManager.Mapped package, which is built specifically to ingest graphs from the Mapped API.

The classes provided by this library are intended to be easily wired up using .Net Dependency Injection, and a ServiceCollection extension method AddIngestionManager() is provided for that express purpose. We recommend that any implementations that you build extend upon this design pattern, and use your own ServiceCollection extension method, which you use to wire up your IInputGraphManager and IGraphIngestionProcessor before then calling out to our extension method that wires up the IOutputGraphManager. This is exactly what the Mapped library does, i.e.:

public static IServiceCollection AddMappedIngestionManager(this IServiceCollection services, Action<MappedIngestionManagerOptions> options)
    {
        services.AddOptions<MappedIngestionManagerOptions>()
                .Configure(options)
                .ValidateDataAnnotations()
                .ValidateOnStart();

        services.AddSingleton<IInputGraphManager, MappedGraphManager>();
        services.AddSingleton<IGraphIngestionProcessor, MappedGraphIngestionProcessor<MappedIngestionManagerOptions>>();

        services.AddIngestionManager(options);

        return services;
    }

Deployment configuration

Once you have implemented IngestionProcessorBase and IInputGraphManager, and a ServiceCollection extension method to wire them up as described above, you are ready to use that extension method and your graph ingestion solution in a real system.

Start by running that extension method to inject all the required interface implementations. Continuing with the Mapped library example, your configuration might look like this:

services.AddLogging();

services.AddSingleton<IOntologyMappingLoader>(sp =>
{
    var logger = sp.GetRequiredService<ILogger<MappedOntologyMappingLoader>>();
    return new MappedOntologyMappingLoader(logger, hostContext.Configuration["ontologyMappingFilename"]);
});

services.AddSingleton<IOntologyMappingManager, OntologyMappingManager>();

services.AddMappedIngestionManager(options =>
{
    // Mapped Specific
    options.MappedToken = hostContext.Configuration["MappedToken"];
    options.MappedRootUrl = hostContext.Configuration["MappedRootUrl"];

    // Ingestion Manager
    options.AzureDigitalTwinsEndpoint = hostContext.Configuration["AzureDigitalTwinsEndpoint"];
});

If all is configured correctly, your code referring to IGraphIngestionProcessor should inject your custom IngestionProcessorBase subclass, on which you can call the inherited method IngestFromApiAsync(). That method will initialise the base processor, and then immediately call your customized ProcessSites() method, kicking off the rest of the ingestion process.

Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on Microsoft.SmartPlaces.Facilities.IngestionManager:

Package Downloads
Microsoft.SmartPlaces.Facilities.IngestionManager.Mapped

Support for converting from a Mapped DTDL-based Ontology to a different DTDL Based Ontology

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
0.6.3-preview 62 9/5/2024
0.6.2-preview 93 9/4/2024
0.6.1-preview 120 2/2/2024
0.6.0-preview 636 1/31/2024
0.5.14-preview 106 7/18/2023
0.5.5-preview 610 6/16/2023
0.5.3-preview 133 6/14/2023
0.4.2-preview 266 5/4/2023
0.4.0-preview 490 2/17/2023
0.3.12-preview 544 12/12/2022
0.3.11-preview 189 12/8/2022
0.3.10-preview 203 12/2/2022
0.3.9-preview 155 11/30/2022
0.3.8-preview 196 11/12/2022
0.2.2-preview 109 11/8/2022
0.2.1-preview 242 11/4/2022
0.2.0-preview 106 11/3/2022
0.1.8-preview 174 11/1/2022
0.1.7-preview 115 10/31/2022
0.1.6-preview 188 10/26/2022
0.1.3-preview 129 10/20/2022
0.1.2-preview 227 10/19/2022
0.1.1-preview 189 10/13/2022
0.1.0-preview 193 10/13/2022