InfraX AI
  • InfraX Network
  • Node
  • App
  • Job
Powered by GitBook
On this page
  • Getting Started
  • Structure
  • States
Export as PDF

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:

# app to concatenate N files

import os

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

input_files = os.listdir('input') # 

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: # 
    f.write('\n'.join(file_contents))

output.txt

Hello
InfraX!

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.

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

import sys
import json

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

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

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.

PreviousNodeNextJob

Last updated 1 month ago