Skip to main content

Forge python SDK

Project description

Forge Python SDK

PyPi version Documentation Discord

Forge is a low code internal tooling platform built on top of Forge that allows developer to build internal tools that integrate directly with their APIs. Forge provides a JavaScript SDK to allow developers to quickly develop Forge apps.

Why choose Forge?

With Forge, all of the code for generating your web UIs lives within your app's codebase. Forge apps are just asynchronous functions that run in your service. Because these are just functions, you can access the complete power of your existing services. When you need to request input or display output, await any of our I/O methods to present a form to the user and your script will pause execution until input is received.

Getting started

To get started with building your first Forge app, all you have to do is define an action. An Action represents a Forge app, which users can define inline or imported. Forge apps can run as a separate background process within your service or as a standalone service. You can get started and create a Forge app in just a few lines of code.

from forgeapp_sdk import Forge, IO

# Initialize Forge
forge = Forge(api_key="<YOUR API KEY>", endpoint: 'wss://<YOUR FORGE SERVER WEBSOCKET URL>/websocket')

@forge.action
async def refund_customer_order(io: IO):
    name = await io.input.text("Order ID")
    return f"Successfully refunded order ID: {orderID}"


# Synchronously listen, blocking forever
forge.listen()

To not block, forge can also be run asynchronously using forge.listen_async(). You must provide your own event loop.

The task will complete as soon as connection to Forge completes, so you likely want to run forever or run alongside another permanent task.

import asyncio, signal

loop = asyncio.get_event_loop()
task = loop.create_task(forge.listen_async())
def handle_done(task: asyncio.Task[None]):
    try:
        task.result()
    except:
        loop.stop()

task.add_done_callback(handle_done)
for sig in {signal.SIGINT, signal.SIGTERM}:
    loop.add_signal_handler(sig, loop.stop)
loop.run_forever()

Forge:

  • Allows you create forge apps as code which integrates directly with your existing functions.
  • Makes creating full-stack apps as easy as writing CLI scripts.
  • Can scale from a handful of scripts to robust multi-user dashboards.

With Forge, you do not need to:

  • Deploy and maintain additional endpoint and/or services to support your forge apps.
  • Give Forge write access to your database or secrets (or give us any of your credentials, for that matter).
  • Work in an external IDE. Integrate directly with your developer environment.

More about Forge

Local Development

This project uses Poetry for dependency management

  1. poetry install to install dependencies
  2. poetry shell to activate the virtual environment

Tasks are configured using poethepoet (installed as a dev dependency).

  • poe demo [demo_name] to run a demo (basic by default if demo_name omitted)
  • poe test to run pytest (can also run pytest directly in virtual env)

Code is formatted using Black. Please configure your editor to format on save using Black, or run poe format to format the code before committing changes.

Tests

Note: Tests currently require a local instance of the Forge backend.

Tests use pytest and playwright.

Currently assumes the test-runner@forgeapp.io user exists already. Run yarn test in the web directory at least once to create it before running these.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

forgeapp_sdk-0.1.1.tar.gz (53.9 kB view details)

Uploaded Source

Built Distribution

forgeapp_sdk-0.1.1-py3-none-any.whl (61.6 kB view details)

Uploaded Python 3

File details

Details for the file forgeapp_sdk-0.1.1.tar.gz.

File metadata

  • Download URL: forgeapp_sdk-0.1.1.tar.gz
  • Upload date:
  • Size: 53.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.4 CPython/3.13.0 Darwin/23.5.0

File hashes

Hashes for forgeapp_sdk-0.1.1.tar.gz
Algorithm Hash digest
SHA256 270bcf18e3da31f1b3c276be7a5a431d24b60f5e76f08b80d9a2bff9d7fc11eb
MD5 e2139fa733213e19f1f1d353b75b258a
BLAKE2b-256 78404f88202a810158f26d649223bcc66db9852376eee9861deaccf10021b34b

See more details on using hashes here.

File details

Details for the file forgeapp_sdk-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: forgeapp_sdk-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 61.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.4 CPython/3.13.0 Darwin/23.5.0

File hashes

Hashes for forgeapp_sdk-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 6e1b0ca7a6aa9a8f23691c57c46953371bb3c402c1021147fae4463029829420
MD5 8682d2b05070c35b8ff173ced8a6fdd1
BLAKE2b-256 1996e2d70a663b4e0767715dba242237be98e25af2a03bfe38f0eac691faaf34

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page