Skip to content

App

An App is a python application that is installed on a Node in the InfraX network. It is used to execute user created Jobs and interact with the InfraX network.

Getting Started

Apps can be tested locally on your machine before being deployed to the InfraX network. To get started with creating an App, follow these steps:

  1. Create a new directory for your App on your local machine.
  2. Inside the directory, create the following subdirectories:
  3. Create a main.py file in the root of the directory. This file should contain the main logic of your App.
  4. (Optional) Create a requirements.txt file in the root of the directory if your App has any dependencies.
  5. Test your App locally by running python main.py in the terminal.
  6. Once your App is working as expected, you can deploy it to the InfraX network by using the frontend interface.

Structure

When the App is run on a Node in the InfraX network, the system will place input files in the input directory and expect output files to be generated in the output directory. Any files placed in the output directory will be collected by the system and made available to the user.

Example main.py file:

main.py
# app to concatenate N files

import os

# .
# └── /
#     └── input/
#         ├── file1.txt - contains 'Hello'
#         └── file2.txt - contains 'InfraX!'

input_files = os.listdir('input') # (1)

file_contents = []
for file in input_files:
    with open(f'input/{file}', 'r') as f:
        file_contents.append(f.read())

with open('output/output.txt', 'w') as f: # (2)
    f.write('\n'.join(file_contents))
  1. Read input files from the input directory. Files are placed in the input directory by the system when a user creates a Job, if the app requires input files.
  2. Generate output files in the output directory
output.txt
Hello
InfraX!

Warning

The input and output directories are created by the system when the App is run on a Node. Do not create these directories yourself as they will be overwritten by the system.

Keyword Arguments

The primary method of nteracting with an App is through files uploaded when a user creates a Job. This should satisfy most use cases. That said, there are some scenarios where additional input is required. This can be achieved by specifying keyword arguments when creating an app through the frontend interface. These arguments will be passed to the App at runtime as stdin keyword arguments.

Note

The maximum length of each argument is 1024 characters. If you require more data, consider requiring a file upload (or multiple files) instead.

Example file with argument message_string="Hello InfraX!" specified:

main.py
1
2
3
4
5
6
import sys
import json

kwargs = json.loads(sys.stdin.read())

print(kwargs)
output
{'message_string': 'Hello InfraX!'}

Info

Any stdout or stderr output generated by the App will be captured by the system and made available to the user in the Job output.

States

An App can be in one of the following states:

CREATED
The App has been created by a user and is ready to be deployed to the InfraX network.
TESTING
The App is being tested by the author to ensure it works as expected. The App is not available for users to discover. Only the author can see the App and create Jobs against the app in this state.
PUBLISHED
The App has been published to the InfraX network and is available for users to discover and create Jobs with. The App can no loger be edited by the author.
HIDDEN
The App has been hidden from the InfraX network and is no longer available for users to discover. The App can no loger be edited by the author.
ERROR
The App has encountered an error and is no longer available for users to discover. The App can no loger be edited by the author.
REMOVED
The App has been removed from the InfraX network and is no longer available for users to discover. The App can no loger be edited by the author.