Job Module¶
Jobs within MIKE Workbench are used as a means to batch commands together and have them executed or scheduled for execution as a single work unit. A scenario where jobs are very useful is with automatic and scheduled execution of model simulations. It is often not enough to just execute the actual simulation but could require pre-processing of input time series for the simulation and post-processing to extract information from the simulation results, check key indicators and possibly submit alerts and notifications.
To maintain jobs, install the NuGet package DHI.MikeOperations.JobManager.
To execute jobs, install the package DHI.MikeOperations.JobManager.JobRunner
The sample below shows how to get a job and execute it in the current process.
var jobModule = application.Modules.Get("Job Manager") as DHI.Solutions.JobManager.Interfaces.IJobModule;
var job = jobModule.JobList.Fetch("/Job-1");
var jobInstance = jobModule.ExecuteLocally(job, job.DefaultTarget);
// Sleep a bit (here 2 seconds) or make sure that the current process still runs when starting the job.
System.Threading.Thread.Sleep(2000);
jobModule = app.Modules.Get("Job Manager")
job = jobModule.JobList.Fetch("/Job-1")
jobInstance = jobModule.ExecuteLocally(job, job.DefaultTarget)
# Sleep a bit (here 2 seconds) or make sure that the current process still runs when starting the job.
System.Threading.Thread.Sleep(2000)
jobModule = DHI.Solutions.JobManager.Interfaces.IJobModule(app.Modules.Get("Job Manager"))
job = jobModule.JobList.Fetch("/Job-1")
jobInstance = jobModule.ExecuteLocally(job, job.DefaultTarget)
# Sleep a bit (here 2 seconds) or make sure that the current process still runs when starting the job.
System.Threading.Thread.Sleep(2000)
Module Providers¶
The following providers are included in the job module.
| Provider | Description |
|---|---|
| JobList | Manage jobs. |
| JobInstanceList | Manage job instances. |
Read more about using module providers here
Using Queries¶
Query Properties¶
Jobs and job instances supports using the following query properties.
Job¶
Query properties supported when querying on jobs in the JobList provider.
| Query Property | Type | Database Column | Note |
|---|---|---|---|
| Computer | string | targetcomputer | |
| Content | string | content | |
| Created | DateTime | created | |
| GroupId | Guid | group_id | |
| Id | Guid | id | |
| JobServiceProviderName | string | provider_name | |
| LastModified | DateTime | lastmodified | |
| Name | string | name | |
| Version | Guid | version |
Job instances¶
Query properties supported when querying on job instances in the JobInstanceList provider.
// Fetch job instances executed with success
var jobModule = app.Modules.Get('Job Manager') as DHI.Solutions.JobManager.Interfaces.IJobModule;
var query = new DHI.Solutions.Generic.Query()
query.Add(DHI.Solutions.Generic.QueryElement("Status", 3, DHI.Solutions.Generic.QueryOperator.Eq));
var jobInstanceList = jobModule.JobInstanceList.Fetch(query);
# Fetch job instances executed with success
jobModule = app.Modules.Get('Job Manager')
query = DHI.Solutions.Generic.Query()
query.Add(DHI.Solutions.Generic.QueryElement("Status", 3, DHI.Solutions.Generic.QueryOperator.Eq))
jobInstanceList = jobModule.JobInstanceList.Fetch(query)
# Fetch job instances executed with success
jobModule = DHI.Solutions.JobManager.Interfaces.IJobModule(app.Modules.Get('Job Manager'))
query = DHI.Solutions.Generic.Query()
query.Add(DHI.Solutions.Generic.QueryElement("Status", 3, DHI.Solutions.Generic.QueryOperator.Eq))
jobInstanceList = jobModule.JobInstanceList.Fetch(query)
| Query Property | Type | Database Column | Note |
|---|---|---|---|
| Computer | string | targetcomputer | |
| CurrentTarget | string | currenttarget | |
| CurrentTask | string | currenttask | |
| ExecutedAt | DateTime | executed | |
| FinishTime | DateTime | finishtime | |
| Id | Guid | id | |
| JobId | Guid | jobid | |
| LastUpdateTime | DateTime | lastupdatetime | |
| Log | string | content | |
| ProcessID | int | processid | |
| ProviderReferenceId | string | provider_ref_id | |
| Status | int | status | NotStarted = 0 Running = 1 CouldNotStart = 2 FinishedSuccess = 3 FinishedError = 4 FinishedUnknown = 5 Terminated = 6 |
| Tag | string | tag | |
| Version | Guid | version |
Remote Providers¶
Remote job providers, allows jobs to be executed remotely on other types of job service. This means that data and database maintenance jobs as well as jobs running simulations can be executed on services running in the cloud.
MIKE Cloud Platform Job Service¶
The MIKE Cloud Platform job service, is a Kubernetes job service able to run Kubernetes jobs as containers.
A number of selected job tasks can be used in jobs being executed using this service.
The container images used to run jobs using the MIKE Cloud PLatform Job Service, contains the following NuGet packages (managers, providers and tools).
| NuGet Package Name | Version added |
|---|---|
| DHI.MikeOperations.Core | 2023 |
| DHI.MikeOperations.Core.Tools.FTPDownload | 2024 |
| DHI.MikeOperations.AnalysisManager | 2024 |
| DHI.MikeOperations.DocumentManager | 2023 |
| DHI.MikeOperations.DocumentManager.Provider.MikeCloud | 2023 |
| DHI.MikeOperations.DocumentManager.Tools.Export | 2023 |
| DHI.MikeOperations.DocumentManager.Tools.Import | 2023 |
| DHI.MikeOperations.DocumentManager.Tools.Query | 2024 |
| DHI.MikeOperations.FavoriteManager | 2023.2 |
| DHI.MikeOperations.GISManager.Provider.MikeCloud.GIS | 2023 |
| DHI.MikeOperations.GISManager.Provider.MikeCloud.Mesh | 2023.2 |
| DHI.MikeOperations.GISManager.Provider.MikeCloud.Raster | 2023 |
| DHI.MikeOperations.GISManager.Provider.Provider.RemoteDfs2 | 2024 |
| DHI.MikeOperations.GISManager.Provider.Provider.RemoteDfsu | 2024 |
| DHI.MikeOperations.GISManager.Provider.Service | 2023.2 |
| DHI.MikeOperations.GISManager.Raster | 2023 |
| DHI.MikeOperations.GISManager.Tools.ASCIIFileImport | 2023.2 |
| DHI.MikeOperations.GISManager.Tools.ASCIIGridFileExport | 2023.2 |
| DHI.MikeOperations.GISManager.Tools.ASCIIGridFileImport | 2023.2 |
| DHI.MikeOperations.GISManager.Tools.ASCIITemporalImport | 2023.2 |
| DHI.MikeOperations.GISManager.Tools.Dfs2Import | 2023 |
| DHI.MikeOperations.GISManager.Tools.Dfs2TemporalRasterFileExport | 2023 |
| DHI.MikeOperations.GISManager.Tools.Dfs3Import | 2023 |
| DHI.MikeOperations.GISManager.Tools.DfsuImport | 2023 |
| DHI.MikeOperations.GISManager.Tools.DfsuToFeaturesImport | 2023.2 |
| DHI.MikeOperations.GISManager.Tools.FeatureClassQuery | 2024 |
| DHI.MikeOperations.GISManager.Tools.FloodedArea | 2024 |
| DHI.MikeOperations.GISManager.Tools.GeoProcessing | 2023.2 |
| DHI.MikeOperations.GISManager.Tools.ImageFileImport | 2023.2 |
| DHI.MikeOperations.GISManager.Tools.ImgRasterImport | 2023.2 |
| DHI.MikeOperations.GISManager.Tools.KmlFileExport | 2023.2 |
| DHI.MikeOperations.GISManager.Tools.KmlFileImport | 2023.2 |
| DHI.MikeOperations.GISManager.Tools.MikeCloudDfsUpload | 2023.2 |
| DHI.MikeOperations.GISManager.Tools.MikeCloudSharedData | 2024 |
| DHI.MikeOperations.GISManager.Tools.RasterInterpolation | 2024 |
| DHI.MikeOperations.GISManager.Tools.RasterProcessing | 2023.2 |
| DHI.MikeOperations.GISManager.Tools.RasterQuery | 2024 |
| DHI.MikeOperations.GISManager.Tools.RasterToDatabase | 2024 |
| DHI.MikeOperations.GISManager.Tools.Res11Import | 2023.2 |
| DHI.MikeOperations.GISManager.Tools.ShapeFileExport | 2023.2 |
| DHI.MikeOperations.GISManager.Tools.ShapeFileImport | 2023.2 |
| DHI.MikeOperations.GISManager.Tools.SoilErosion | 2024 |
| DHI.MikeOperations.GISManager.Tools.SoilErosionR | 2024 |
| DHI.MikeOperations.GISManager.Tools.TemporalRaster | 2024 |
| DHI.MikeOperations.GISManager.Tools.TiffImport | 2023.2 |
| DHI.MikeOperations.GISManager.Tools.TiffTemporalImport | 2023.2 |
| DHI.MikeOperations.GISManager.Tools.ToDatabase | 2024 |
| DHI.MikeOperations.IndicatorManager | 2023 |
| DHI.MikeOperations.JobManager | 2023 |
| DHI.MikeOperations.JobManager.JobServiceProviderMikeCloud | 2023.2 |
| DHI.MikeOperations.JobManager.Tools.JobExport | 2023 |
| DHI.MikeOperations.MetadataManager | 2023 |
| DHI.MikeOperations.PlacesManager | 2023 |
| DHI.MikeOperations.ScenarioManager | 2023 |
| DHI.MikeOperations.ScenarioManager.Adapters.MIKE11 | 2024 |
| DHI.MikeOperations.ScenarioManager.Adapters.MIKE1D | 2023 |
| DHI.MikeOperations.ScenarioManager.Adapters.MIKE21FM | 2023 |
| DHI.MikeOperations.ScenarioManager.Adapters.MIKEFlood | 2023 |
| DHI.MikeOperations.ScenarioManager.Adapters.MIKESHE | 2023.2 |
| DHI.MikeOperations.ScenarioManager.Execution.MikeCloud | 2023 |
| DHI.MikeOperations.ScriptManager.IronPython | 2023 |
| DHI.MikeOperations.ScriptManager.Provider.DevOps | 2024 |
| DHI.MikeOperations.ScriptManager.Provider.GitHub | 2024 |
| DHI.MikeOperations.ScriptManager.Tools.Query | 2024 |
| DHI.MikeOperations.SpreadsheetManager | 2023 |
| DHI.MikeOperations.SpreadsheetManager.Functions.GIS | 2023.2 |
| DHI.MikeOperations.SpreadsheetManager.Functions.Indicator | 2023.2 |
| DHI.MikeOperations.SpreadsheetManager.Functions.Spreadsheet | 2023.2 |
| DHI.MikeOperations.SpreadsheetManager.Functions.Timeseries | 2023.2 |
| DHI.MikeOperations.SpreadsheetManager.Tools.ExportSpreadsheet | 2024 |
| DHI.MikeOperations.SpreadsheetManager.Tools.ImportSpreadsheet | 2024 |
| DHI.MikeOperations.SpreadsheetManager.Tools.Query | 2024 |
| DHI.MikeOperations.SystemManager | 2023 |
| DHI.MikeOperations.TimeseriesManager | 2023 |
| DHI.MikeOperations.TimeseriesManager.Provider.MikeCloud | 2023 |
| DHI.MikeOperations.TimeseriesManager.Provider.MikeOperations | 2023.2 |
| DHI.MikeOperations.TimeseriesManager.Tools.AdvancedStatistics | 2023 |
| DHI.MikeOperations.TimeseriesManager.Tools.BasicStatistics | 2023 |
| DHI.MikeOperations.TimeseriesManager.Tools.Differences | 2024 |
| DHI.MikeOperations.TimeseriesManager.Tools.ExtremeValues | 2023.2 |
| DHI.MikeOperations.TimeseriesManager.Tools.ImportTools | 2023 |
| DHI.MikeOperations.TimeseriesManager.Tools.ImportTools.USGS | 2023 |
| DHI.MikeOperations.TimeseriesManager.Tools.MikeCloudUpload | 2023 |
| DHI.MikeOperations.TimeseriesManager.Tools.NearestNeighbourResampling | 2024 |
| DHI.MikeOperations.TimeseriesManager.Tools.PeriodStatistics | 2024 |
| DHI.MikeOperations.TimeseriesManager.Tools.PolynomialRegression | 2024 |
| DHI.MikeOperations.TimeseriesManager.Tools.Processing | 2023 |
| DHI.MikeOperations.TimeseriesManager.Tools.TimeseriesExport | 2023 |
| DHI.MikeOperations.TimeseriesManager.Tools.TimeseriesQuery | 2024 |
| DHI.MikeOperations.TimeseriesManager.Tools.ToDatabase | 2024 |
| DHI.MikeOperations.TimeseriesManager.Tools.ToFeatureClass | 2024 |
| DHI.MikeOperations.TimeseriesManager.Tools.TsUtilities | 2023.2 |
| DHI.MikeCore.Linux.rhel7 | 2023 |
| Npgsql | 2023 |
Tools¶
When using the API for running tools, every tool are following the concept show below.
// Get the tool from the tool name.
var tool = application.Tools.CreateNew("Job export tool") as DHI.Solutions.JobManager.Tools.JobExportTool.IJobExportTool;
// Add input items to the tool.
tool.InputItems.Add(job);
// Set the properties of the tool.
tool.Group = "/MyGroup";
// Execute the tool.
tool.Execute();
// Get the output of the tool (if any).
var output = tool.OutputItems[0];
# Get the tool from the tool name.
tool = app.Tools.CreateNew("Job export tool")
# Add input items to the tool.
tool.InputItems.Add(job)
# Set the properties of the tool.
tool.Group = "/MyGroup"
# Execute the tool.
tool.Execute()
# Get the output of the tool (if any).
var output = tool.OutputItems[0]
# Get the tool from the tool name.
tool = DHI.Solutions.JobManager.Tools.JobExportTool.IJobExportTool(app.Tools.CreateNew("Job export tool"))
# Add input items to the tool.
tool.InputItems.Add(job)
# Set the properties of the tool.
tool.Group = "/MyGroup"
# Execute the tool.
tool.Execute()
# Get the output of the tool (if any).
var output = tool.OutputItems[0]
Job export tool¶
Tool for exporting jobs to files on disk.
| Tool Info | Job export tool |
|---|---|
| NuGet Package | DHI.MikeOperations.JobManager.Tools.JobExport |
| API Reference | DHI.Solutions.JobManager.Tools.JobExportTool.IJobExportTool |
| Input Items | One or more jobs |
| Output Items | No output items |
Tool Properties
- ExportFormat: Gets or sets the export format
- ExportPath: Gets or sets the export path
- Group: Gets or sets the group of the spreadsheet
- SpreadSheetName: Gets or sets the name of the spreadsheet
Code Sample
// Get the tool.
var tool = application.Tools.CreateNew("Job export tool") as DHI.Solutions.JobManager.Tools.JobExportTool.IJobExportTool;
# Get the tool.
tool = app.Tools.CreateNew("Job export tool")
# Get the tool.
tool = DHI.Solutions.JobManager.Tools.JobExportTool.IJobExportTool(app.Tools.CreateNew("Job export tool"))