Deepomatic Platform
  • Overview
  • Release notes
    • May 2025
    • January 2025
    • November 21, 2024
    • October 17, 2024
    • September 19, 2024
    • July 18, 2024
    • June 27, 2024
    • May 23, 2024
    • April 18, 2024
    • March 21, 2024
    • February 22, 2024
    • January 18, 2024
    • December 13, 2023
    • October 26, 2023
    • July 20, 2023
    • June 29, 2023
    • May 29, 2023
    • April 27, 2023
    • March 30, 2023
    • February 17, 2023
    • January 19, 2023
    • December 22, 2022
    • November 18, 2022
    • October 19, 2022
    • September 19, 2022
    • July 27, 2022
    • June 26, 2022
    • May 17, 2022
    • April 13, 2022
    • March 17, 2022
    • February 10, 2022
    • December 21, 2021
    • October 26, 2021
  • Getting started
  • ADMIN & USER MANAGEMENT
    • Invite and manage users
      • Invite group of users at once
      • SSO
        • OIDC
        • SAML
  • Deepomatic Engage
    • Integrate applications
      • Deepomatic vocabulary
      • Deepomatic connectors
        • Set-up
        • Camera Connector
        • Work Order Connector
      • API integration
        • Authentication
        • Errors
        • API reference
          • Work order management
          • Analysis
            • Guide field workers
            • Perform an analysis
            • Correct an analysis
          • Data retrieval
          • Endpoints' list
      • Batch processing
        • Format
        • Naming conventions
        • Processing
        • Batch status & errors
      • Data export
    • Use the mobile application
      • Configure a mobile application
      • Create & visualize work orders
      • Complete work orders
      • Offline experience
    • Manage your business operations with customisable solutions
      • Roles
      • Alerting
      • Field services
        • Reviewing work orders
        • Exploring work orders
        • Grouping work orders
        • Monitoring assets performance
      • Insights
  • Security
    • Security
    • Data Protection
Powered by GitBook
On this page
  • Python script
  • Deepomatic CLI

Was this helpful?

  1. Deepomatic Engage
  2. Integrate applications
  3. Batch processing

Processing

To upload and start processing a batch, you must use the Deepomatic API.

Was this helpful?

When it comes to the batch processing, there are two ways to use the Deepomatic API: Python script or Deepomatic CLI.

Python script

Run the python script below with the following arguments:

  • endpoint: it corresponds to the deployment site and has the following URL: https://api.{site-id}.customers.deepomatic.com. For more information on how to retrieve, please refer to the .

  • filename: it corresponds to the local path of the archive with the format specified .

Script execution
python3 upload.py endpoint filename
upload.py
import sys

import requests


CHUNK_SIZE = 262144 * 2


def upload(endpoint: str, filepath: str):
    # Setup base headers with auth token
    headers = {
        'Authorization': f'Token {os.getenv("CUSTOMER_API_KEY")}',
        'content-type': 'application/json'
    }
    # Use endpoint to get a resumable url
    try:
        response = requests.post(
            f"{endpoint}/v0.2/batches",
            headers=headers
        )
        # check for bad answers
        response.raise_for_status()
        resumable_url = response.json()["upload_url"]
    except Exception as err:
        print(err)
        sys.exit(1)

    print(f"Using resumable_url: {resumable_url}")
    # Setup chunk tracking variables
    index = 0
    offset = 0
    content_size = os.stat(filepath).st_size

    # No more auth on the resumable_url.
    # Setting content-type
    headers = {
        'content-type': 'application/octet-stream'
    }
    with open(filepath, "rb") as archive:
        while True:
            chunk = archive.read(CHUNK_SIZE)
            if not chunk:
                break
            offset = index + len(chunk)
            headers['Content-Range'] = 'bytes %s-%s/%s' % (index, offset - 1, content_size)
            index = offset
            try:
                response = requests.put(resumable_url, data=chunk, headers=headers)
                print("response: %s, Content-Range: %s" % (response, headers['Content-Range']))
                print(response.text)
                response.raise_for_status()
            except Exception as err:
                print(err)


if __name__ == "__main__":
    if "--help" in sys.argv or len(sys.argv) != 3:
        print(
            "Usage:"
            "   upload.py <endpoint> <filepath>"
        )
    upload(sys.argv[1], sys.argv[2])

Deepomatic CLI

Use the following command and specify:

  • either the batch id if you have already created the batch via the GUI or the upload url if this is not the case

  • the archive path

Batch processing
deepo site work_order batch upload -i batch_id -u upload_url -f archive_path
Authentication documentation
here