Skip to main content

OneCompute

Python package for integration with the OneCompute cloud platform. Streamline job management, workflows, and file operations over REST APIs. Monitor job progress and efficiently handle file uploads and downloads.

Empower your Python workflows with seamless integration using our advanced OneCompute cloud platform package. Effortlessly manage complex jobs, streamline workflows, and facilitate efficient file operations through our user-friendly REST APIs. Process workflows both locally and on the cloud to optimize performance and resource utilization. Stay on top of job progress with real-time monitoring capabilities and experience hassle-free handling of file uploads and downloads for a truly streamlined cloud computing experience.

Usage

Introduction

This project demonstrates how to run a workflow locally using the OneCompute platform. The provided code snippet utilizes the dnv-oneworkflow Python package to interact with the OneCompute platform and execute a simple workflow locally. The example showcases the setup of the local workflow runtime service and the submission of a job for execution.

Prerequisites

Make sure you have the following prerequisites installed:

  • Python 3.10.x or higher

  • Pip (Python package manager)

  • dnv-oneworkflow Python package for the PythonCommand module.

    Use the following command to install the dnv.oneworkflow package:

    pip install dnv.oneworkflow
    
  • Install the LocalWorkflowRuntimeService using the following command within your Python environment:

    await PackageManager().install_package_async(
        "LocalWorkflowRuntime", "win-x64", PackageManager.Repository.DEV
    )
    

Code

import asyncio
import os

from dnv.onecompute import (
    AutoDeployOption,
    Job,
    LocalWorkflowRuntimeServiceManager,
    OneComputeClient,
    WorkUnit,
)
from dnv.oneworkflow.python_command import PythonCommand


async def run_workflow_locally_async():
    """
    Run a workflow locally using the OneCompute platform.
    """
    # Define constants
    OC_APPS_PATH = os.path.join(os.environ["LOCALAPPDATA"], "OneCompute")
    RUNTIME_SERVICE_PATH = os.path.join(OC_APPS_PATH, "LocalWorkflowRuntime", "wc.exe")
    WORKSPACE_ID = "MyWorkspace"
    SERVICE_NAME = "OneWorkflowWorkerHost"

    # Configure the local workflow runtime service
    workflow_runtime_service = LocalWorkflowRuntimeServiceManager(
        workspace_id=WORKSPACE_ID,
        worker_host_apps_path=OC_APPS_PATH,
        workflow_runtime_executable_path=RUNTIME_SERVICE_PATH,
        console_window_visible=True,
        auto_deploy_option=AutoDeployOption.DEV,
        startup_wait_time=10,
    )

    # Set up the OneCompute client
    url = workflow_runtime_service.workflow_runtime_service_endpoint
    oc_client = OneComputeClient(base_url=url, authenticator=None)

    # Start the local workflow runtime service
    workflow_runtime_service.start_service()

    # Define the Python command for the work unit
    py_cmd = PythonCommand(inline_script="print('Hello OneCompute')")
    work_unit = WorkUnit(py_cmd)
    work_unit.command = SERVICE_NAME

    # Define the job with necessary configurations
    job = Job()
    job.work = work_unit
    job.service_name = SERVICE_NAME
    job.properties = {"OW_WorkspaceId": WORKSPACE_ID}

    # Submit the job and await its termination
    job_monitor = await oc_client.submit_job_async(job)
    await job_monitor.await_job_termination_async()

    # Stop the local workflow runtime service
    workflow_runtime_service.stop_service()


if __name__ == "__main__":
    # Run the main asynchronous function
    asyncio.run(run_workflow_locally_async())

License

MIT

Support

If you encounter any issues, have questions, or want to provide feedback, please get in touch with our support team at software.support@dnv.com. We are committed to continuously improving OneCompute and providing timely assistance to our users.

Metadata

Release files for dnv-onecompute 12.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for dnv-onecompute 12.3.0
File Size Uploaded Provenance Actions
dnv_onecompute-12.3.0.tar.gz 47.9 kB Without provenance Details for dnv_onecompute-12.3.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for dnv-onecompute 12.3.0
File Interpreter ABI Platform Actions
dnv_onecompute-12.3.0-py3-none-any.whl Python 3 none any Details for dnv_onecompute-12.3.0-py3-none-any.whl

Total release size: 103.3 kB

Release files / dnv_onecompute-12.3.0.tar.gz

Download URL dnv_onecompute-12.3.0.tar.gz
Size 47.9 kB
Tags Source
SHA-256 checksum
How to use checksums
a505ca8fcd092717c170a238fac23671aae692604b115f22550bb03901e90fd5
BLAKE2b-256 checksum
How to use checksums
b692413a2ee1ce7227e42e199e70089958e4edf627caaf8541eea326b00a2405
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.10

Release files / dnv_onecompute-12.3.0-py3-none-any.whl

Download URL dnv_onecompute-12.3.0-py3-none-any.whl
Size 55.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
abb1824a902473e3bf9ea0e687591ec6d2edfbbd006c6d2956576832adbb5aca
BLAKE2b-256 checksum
How to use checksums
7966857e388c0e6c27fd6b3ef7a30a4bd5d52029edc8359f8c9cac1a144485a1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.10

Security for dnv-onecompute 12.3.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page