Configuration options
- Python
- C#
- C / C++
The Pipeline.from_denkflow(file_name, **kwargs) method is the primary way to load pre-built .denkflow pipelines. Here are several configuration options for different scenarios:
from denkflow import Pipeline, HubLicenseSource, OneTimeLicenseSource
# Common parameters (replace with your actual values)
denkflow_file_path = "path/to/your_model.denkflow"
your_pat = "YOUR-PERSONAL-ACCESS-TOKEN"
your_license_id = "YOUR-LICENSE-ID" # Optional
custom_hub_endpoint = "https://your.custom.hub.endpoint" # Optional
# 1. Basic: Using PAT only (Recommended for simplicity)
# DENKflow uses the PAT to handle licensing, typically creating a HubLicenseSource internally.
pipeline_pat_only = Pipeline.from_denkflow(denkflow_file_path, pat=your_pat)
print("Pipeline loaded using PAT only.")
# 2. PAT with a specific License ID
# Useful if your PAT has access to multiple licenses and you need to select one.
pipeline_pat_license_id = Pipeline.from_denkflow(
denkflow_file_path,
pat=your_pat,
license_id=your_license_id
)
print(f"Pipeline loaded using PAT and License ID: {your_license_id}")
# 3. PAT with a custom Hub endpoint
# For testing instances of the DENKweit Vision AI Hub.
pipeline_pat_custom_endpoint = Pipeline.from_denkflow(
denkflow_file_path,
pat=your_pat,
endpoint=custom_hub_endpoint
)
print(f"Pipeline loaded using PAT and custom endpoint: {custom_hub_endpoint}")
# 4. Using a pre-configured HubLicenseSource
# Provides more control over license source creation.
hub_license_source = HubLicenseSource.from_pat(pat=your_pat, license_id=your_license_id)
pipeline_hub_ls = Pipeline.from_denkflow(
denkflow_file_path,
license_source=hub_license_source
)
print("Pipeline loaded using a pre-configured HubLicenseSource.")
# 5. Using a pre-configured OneTimeLicenseSource
initial_hub_src = HubLicenseSource.from_pat(pat=your_pat, license_id=your_license_id)
one_time_license_source = initial_hub_src.to_one_time_license_source()
pipeline_one_time_ls = Pipeline.from_denkflow(
denkflow_file_path,
license_source=one_time_license_source
)
print("Pipeline loaded using a pre-configured OneTimeLicenseSource.")
# 6. PAT with `one_time_registration=True` (Enables offline use after first run)
pipeline_one_time_reg = Pipeline.from_denkflow(
denkflow_file_path,
pat=your_pat,
one_time_registration=True
)
print("Pipeline loaded using PAT with one_time_registration=True.")
Parameter reference
The Pipeline.from_denkflow method accepts the following key parameters:
file_name: str(Required): The path to your.denkflowmodel file.pat: Optional[str] = None: Your Personal Access Token from the Vision AI Hub.license_source: Optional[HubLicenseSource | OneTimeLicenseSource] = None: A pre-configured license source object.license_id: Optional[str] = None: Whenpatis used for licensing, this optionally specifies alicense_id.endpoint: Optional[str] = None: Custom URL for the Vision AI Hub endpoint.one_time_registration: bool = False: WhenTrue, enables offline use after the first successful run.
Pipeline.FromDenkflow accepts an optional LicenseSource; provide one when
the graph requires licensing. Unlike Python, it has no PAT, license ID,
endpoint, or one-time-registration shorthand parameters.
using DenkFlow;
var denkflowFilePath = "path/to/your_model.denkflow";
var pat = "YOUR-PERSONAL-ACCESS-TOKEN";
var licenseId = "YOUR-LICENSE-ID"; // Optional
var customHubEndpoint = "https://your.custom.hub.endpoint"; // Optional
// PAT only.
using var hub = HubLicenseSource.FromPat(pat);
using var pipeline = Pipeline.FromDenkflow(denkflowFilePath, hub);
// PAT with a license ID and custom endpoint.
using var configuredHub = HubLicenseSource.FromPat(
pat,
licenseId: licenseId,
endpoint: customHubEndpoint);
using var configuredPipeline =
Pipeline.FromDenkflow(denkflowFilePath, configuredHub);
// Cache a one-time license source for a long-running service.
using var initialHub = HubLicenseSource.FromPat(pat, licenseId);
using var oneTime = initialHub.ToOneTimeLicenseSource();
using var oneTimePipeline = Pipeline.FromDenkflow(denkflowFilePath, oneTime);
oneTime.Refresh();
// Only for an unencrypted graph that does not contact the Hub.
using var noLicense = new NullLicenseSource();
using var unencryptedPipeline =
Pipeline.FromDenkflow("unencrypted.denkflow", noLicense);
HubLicenseSource.FromPat(pat, licenseId: null, endpoint: null) uses the
default Hub endpoint when endpoint is omitted. Pipeline.FromDenkflow takes
only filename and an optional LicenseSource; create and pass a
OneTimeLicenseSource explicitly when that behavior is needed.
There are different options when creating a HubLicenseSource:
// Create a HubLicensSource using only a PAT
DenkflowHubLicenseSource* hub_license_source = NULL;
const char* pat = "personal_access_token";
denkflow_hub_license_source_from_pat(&hub_license_source, pat, NULL, NULL);
// Create a HubLicensSource using a PAT and a custom license ID
DenkflowHubLicenseSource* hub_license_source = NULL;
const char* pat = "personal_access_token";
const char* license_id = "license_id";
denkflow_hub_license_source_from_pat(&hub_license_source, pat, license_id, NULL);
// Create a HubLicensSource using a PAT and a custom endpoint
DenkflowHubLicenseSource* hub_license_source = NULL;
const char* pat = "personal_access_token";
const char* endpoint = "alternative_endpoint";
denkflow_hub_license_source_from_pat(&hub_license_source, pat, NULL, endpoint);
// Create a DenkflowOneTimeLicenseSource from a HubLicensSource
DenkflowHubLicenseSource* hub_license_source = NULL;
DenkflowOneTimeLicenseSource* one_time_license_source = NULL;
denkflow_hub_license_source_to_one_time_license_source(&one_time_license_source, &hub_license_source);
After creating the license source, the pipeline can be created via:
DenkflowPipeline* pipeline = NULL;
const char* model_file = "path/to/model/file.denkflow";
denkflow_pipeline_from_denkflow(&pipeline, model_file, (void*)license_source);
Important Notes:
- Use the single Python package,
pip install denkflow. Execution providers are selected by the exported graph or withset_node_device()before initialization; they are not selected with Python package extras. Aset_node_device()override requires the requested provider dependency to have been installed already. - Pipeline initialization also resolves native dependencies. ONNX Runtime
1.22.1 is always managed under
<data dir>/dependencies/onnxruntime/; CUDA, TensorRT, DirectML, and OpenVINO use a compatible system install or a managed dependency. - The first initialization may use the license source's Hub credentials to
download missing dependencies. Set
DENKFLOW_NONINTERACTIVE=1for unattended startup, or place matching.denkdependencyarchives in<data dir>/dependencies/or the dependency import directory for offline startup. - Ensure the SDK data directory is on persistent storage. In Docker you can
mount a host volume at the default path (for Linux as
root,/root/.config/denkflow) without settingDENKFLOW_DATA_DIRECTORY; otherwise set the variable and mount a volume at that path. This preserves dependencies, offline license state, and provider caches. ORT_DYLIB_PATHis only an advanced override for an intentionally supplied ONNX Runtime build; normal deployments use the SDK-managed runtime.- If both
patandlicense_sourceare provided, thelicense_sourcetakes precedence. - In C#, there is no equivalent ambiguous combination:
Pipeline.FromDenkflow(filename, licenseSource)accepts an explicit source and does not accept a PAT directly.
Thread configuration
You can configure the number of threads used by ONNX Runtime for model inference. This allows you to optimize performance based on your hardware and workload.
- Python
- C#
- C / C++
from denkflow import Pipeline
# Create a pipeline
pipeline = Pipeline.from_denkflow("path/to/model.denkflow", pat="your_pat")
# Configure thread counts (must be done before initialize())
pipeline.set_intra_threads(8) # Threads for parallelism within operators
pipeline.set_inter_threads(2) # Threads for parallelism between operators
# Initialize the pipeline
pipeline.initialize()
Thread configuration methods
set_intra_threads(intra_threads: int): Sets the number of intra-op threads. Controls parallelism within individual nodes/operators. Default is 4.set_inter_threads(inter_threads: int): Sets the number of inter-op threads. Controls parallelism between independent nodes/operators. Default is 4.
Note: These methods must be called before pipeline.initialize(). Calling them after initialization will raise a RuntimeError.
Performance tuning tips
- Intra-op threads: Higher values (8-16) can improve performance for compute-intensive operations on multi-core CPUs.
- Inter-op threads: Lower values (2-4) are typically sufficient, as most pipelines have sequential dependencies.
- Start with the defaults (4/4) and adjust based on profiling results.
using DenkFlow;
using var license = HubLicenseSource.FromPat("your_pat");
using var pipeline =
Pipeline.FromDenkflow("path/to/model.denkflow", license);
// Configure before Initialize().
pipeline.SetIntraThreads(8);
pipeline.SetInterThreads(2);
pipeline.Initialize();
Thread configuration methods
SetIntraThreads(nuint threadCount)controls parallelism within operators.SetInterThreads(nuint threadCount)controls parallelism between independent operators.
Both methods are building-phase operations. Calling either after
Initialize() throws InvalidOperationException.
// Create a pipeline
DenkflowPipeline* pipeline = NULL;
denkflow_pipeline_from_denkflow(&pipeline, "path/to/model.denkflow", (void*)license_source);
// Configure thread counts (must be done before denkflow_initialize_pipeline())
denkflow_pipeline_with_intra_threads(pipeline, 8); // Threads for parallelism within operators
denkflow_pipeline_with_inter_threads(pipeline, 2); // Threads for parallelism between operators
// Initialize the pipeline
DenkflowInitializedPipeline* initialized_pipeline = NULL;
denkflow_initialize_pipeline(&initialized_pipeline, &pipeline);
Thread configuration functions
denkflow_pipeline_with_intra_threads(pipeline, intra_threads): Sets the number of intra-op threads. Controls parallelism within individual nodes/operators. Default is 4.denkflow_pipeline_with_inter_threads(pipeline, inter_threads): Sets the number of inter-op threads. Controls parallelism between independent nodes/operators. Default is 4.
Note: These functions must be called before denkflow_initialize_pipeline(). The pipeline object remains valid after these calls.