LogoLogo
Go ToJoin the Community
  • Getting Started
    • Introduction
    • How it Works
    • Onboarding
  • Examples
    • Tutorials
      • Hello, World!
      • Image Generation w/ Stable Diffusion
  • CREATE WITH BYTENITE
    • Building Blocks
      • Apps
      • Job Templates
  • SDK
    • ByteNite Dev CLI
  • Launch with ByteNite
    • Data Sources
      • AWS S3
      • Google Cloud Storage
      • Storj
      • HTTP
      • File Upload
      • Temporary Bucket
    • Jobs
  • API Reference
    • Customer API
      • Jobs
        • Create
        • Read
        • Update
        • Manage
        • Other
      • Logs
      • Data Sources
      • Templates
      • Events
    • Authentication API
      • Access Token
      • API Keys
      • Secrets
      • User
    • Developer API
      • Apps
        • Metadata
        • Push
        • Manage
        • Pull
      • Engines
        • Metadata
        • Push
        • Manage
        • Pull
      • Templates
    • Wallet API
      • Balance
      • Transactions
      • Exchange Rate
      • Redeem Coupon
  • GUI
  • Other
    • Glossary
    • Feature Requests
    • Status
Powered by GitBook

© 2025 ByteNite Inc.

On this page

Was this helpful?

Export as PDF
  1. Examples
  2. Tutorials

Hello, World!

PreviousTutorialsNextImage Generation w/ Stable Diffusion

Last updated 10 days ago

Was this helpful?

The goal of this tutorial is to build a simple ByteNite app that outputs the string "Hello, World!" to a file. Use this tutorial if you're new to ByteNite and want to have a quick sense of the workflow.

Duration
Difficulty
Prerequisites

~15 min

Very Easy


1

Download sample app

Run the app new command in your terminal to create an app directory locally named "hello-world":

bytenite app new hello-world

Check that a new directory named "hello-world" was indeed created at your base path:

ls
2

Write the main script

Locate your pre-generated Python entry point (./hello-world/app/main.py) and add the code to the file.

We'll make the app perform a few simple steps:

  • Read a string from the input text file (chunk).

  • Convert the string to a case matching the input parameter 'case'.

  • Write the result to a text file in the task results directory.

main.py
if __name__ == '__main__':
    print("Python task started")
    result_path = os.path.join(task_results_dir, 'processed_chunk.txt')
    try:
         # 1. Reading Inputs
    
        # Expect a text file to be passed by the partitioner
        with open(chunk_path, 'r', encoding="utf-8") as infile:
            my_string = infile.read()

        # 2. Handling Parameters
        
        # Expect the job parameters to have a key named 'case', and the options to be "upper", "lower", and "title"
        case = app_params['case']

        # 3. Developing the Core Functionality
        
        # Process the string based on the case parameter
        if case == "upper":
            my_string = my_string.upper()
        elif case == "lower":
            my_string = my_string.lower()
        elif case == "title":
            my_string = my_string.title()
        else:
            my_string = my_string
        
        # 4. Saving Outputs

        # Save the string directly into a text file to the default task results directory
        with open(os.path.join(task_results_dir, "hello_world_processed.txt"), 'w', encoding="utf-8") as outfile:
            outfile.write(my_string)

    except Exception as e:
        print("Python exception: ", e)
        raise e
3

Check your manifest and template files

The manifest and template files are automatically generated and located in your hello-world directory. Ensure they contain the correct configurations as shown below.

Note: We're using passthrough partitioning and assembling engines in this template, so there's no need to configure these components.

manifest.json
{
  "name": "hello-world",
  "version": "0.1",
  "platform": "docker",
  "description": "An app named hello-world",
  "entrypoint": "main.py",
  "platform_config": {
    "container": "python:latest"
  },
  "device_requirements": {
    "min_cpu": 2,
    "min_memory": 2
  }
}
template.json
{
  "id": "hello-world-template",
  "description": "A template for hello-world",
  "app": "hello-world",
  "partitioner": "passthrough",
  "assembler": "passthrough"
}
4

Submit and activate your app

Upload the content of your app:

bytenite app push hello-world

Activate your app to make it accept jobs:

bytenite app activate hello-world

Now, check your app's details and status by running the command:

bytenite app get hello-world

Finally, ensure that your template was correctly uploaded—you will need that for running jobs.

bytenite template get hello-world-template

5

Launch a job with 'hello-world-template'

Let's launch a job with your new hello-world-template and test your app.

Send a POST request to the Job Create endpoint, including the following fields in the request body:

Key
Value

templateId

hello-world-template

dataSource

dataDestination

params

Then, launch your job and check the results.

Here's a Postman collection that you can use to run your Hello World job:

{
    "dataSourceDescriptor": "url",
    "params": {
        "@type": "type.googleapis.com/bytenite.data_source.HttpDataSource",
        "url": "https://storage.googleapis.com/video-test-public/hello-world-I.txt"
    }
}
{
    "dataSourceDescriptor": "bucket"
}
{
    "app": {
        "case": "upper"
    }
}
Onboarding
ByteNite Dev CLI
LogoTutorial: Hello, World! | ByteNite API DemosPostman