Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into mocked
Browse files Browse the repository at this point in the history
  • Loading branch information
amh4r committed Oct 4, 2024
2 parents 6195789 + 38accc1 commit 37f40af
Show file tree
Hide file tree
Showing 80 changed files with 1,394 additions and 1,003 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@ on:
paths:
- ".github/**"
- "Makefile"
- "constraints.txt"
- "examples/**"
- "inngest/**"
- "pyproject.toml"
- "tests/**"

jobs:
Expand Down
13 changes: 1 addition & 12 deletions LICENSE.md
Original file line number Diff line number Diff line change
Expand Up @@ -175,18 +175,7 @@

END OF TERMS AND CONDITIONS

APPENDIX: How to apply the Apache License to your work.

To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.

Copyright [yyyy] [name of copyright owner]
Copyright 2022 Inngest Inc.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ format-check: check-venv
@ruff format .

install: check-venv
@pip install '.[extra]' -c constraints.txt
@pip install -e '.[extra]' -c constraints.txt

itest: check-venv
@pytest -n 4 -v tests
Expand Down
12 changes: 9 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<br/>
<p>
Serverless event-driven queues, background jobs, and scheduled jobs for Python.<br />
Works with any framework and platform.
Add durable functions and workflows to any framework and platform.
</p>
Read the <a href="https://www.inngest.com/docs?ref=github-inngest-js-readme">documentation</a> and get started in minutes.
<br/>
Expand All @@ -23,6 +23,9 @@

# Inngest Python SDK

Inngest's SDK adds durable functions to Python in a few lines of code. Using this SDK, you can write
background jobs as step functions without new queueing infrastructure such as celery.

We currently support the following frameworks (but adding a new framework is easy!):

- DigitalOcean Functions
Expand All @@ -47,7 +50,7 @@ Python 3.9 is the minimum version we support.

### Basic (no steps)

This is a minimal example of an Inngest function. It's missing some of our features but it's a good starting point.
This is a minimal example of an Inngest function:

```py
import flask
Expand Down Expand Up @@ -83,7 +86,10 @@ inngest.flask.serve(
app.run(port=8000)
```

Send the following event in the Dev Server UI and the `fetch_person` function will run:
[Each function is automatically backed by its own queue](https://www.inngest.com/docs/learn/how-functions-are-executed). Functions can contain steps, which act as code
level transactions. Each step retries on failure, and runs once on success. Function state is automatically managed.

Let's run the function. Send the following event in the [local development server (Dev Server UI)](https://www.inngest.com/docs/local-development) and the `fetch_person` function will run:

```json
{
Expand Down
6 changes: 3 additions & 3 deletions examples/digital_ocean/app.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
from src.inngest import inngest_client
from src.inngest.client import inngest_client
from src.inngest.functions import hello

import inngest.digital_ocean
from examples import functions
from inngest.experimental.digital_ocean_simulator import DigitalOceanSimulator

main = inngest.digital_ocean.serve(
inngest_client,
functions.create_sync_functions(inngest_client),
[hello],
)

# This should not be used in production. It's just for locally running
Expand Down
3 changes: 0 additions & 3 deletions examples/digital_ocean/src/inngest/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +0,0 @@
from .client import inngest_client

__all__ = ["inngest_client"]
14 changes: 14 additions & 0 deletions examples/digital_ocean/src/inngest/functions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import inngest

from .client import inngest_client


@inngest_client.create_function(
fn_id="hello-world",
trigger=inngest.TriggerEvent(event="say-hello"),
)
def hello(
ctx: inngest.Context,
step: inngest.StepSync,
) -> str:
return "Hello world!"
14 changes: 14 additions & 0 deletions examples/django/inngest_django/functions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import inngest

from .inngest_client import inngest_client


@inngest_client.create_function(
fn_id="hello-world",
trigger=inngest.TriggerEvent(event="say-hello"),
)
def hello(
ctx: inngest.Context,
step: inngest.StepSync,
) -> str:
return "Hello world!"
4 changes: 2 additions & 2 deletions examples/django/inngest_django/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
from django.urls import path

import inngest.django
from examples import functions

from .functions import hello
from .inngest_client import inngest_client

urlpatterns = [
path("admin/", admin.site.urls),
inngest.django.serve(
inngest_client,
functions.create_sync_functions(inngest_client),
[hello],
),
]
6 changes: 3 additions & 3 deletions examples/fast_api/app.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import fastapi
from src.inngest import inngest_client
from src.inngest.client import inngest_client
from src.inngest.functions import hello

import inngest.fast_api
from examples import functions

app = fastapi.FastAPI()


inngest.fast_api.serve(
app,
inngest_client,
functions.create_async_functions(inngest_client),
[hello],
)
3 changes: 0 additions & 3 deletions examples/fast_api/src/inngest/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +0,0 @@
from .client import inngest_client

__all__ = ["inngest_client"]
3 changes: 1 addition & 2 deletions examples/fast_api/src/inngest/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@

import inngest

logger = logging.getLogger(__name__)
logger.addHandler(logging.StreamHandler())
logger = logging.getLogger("uvicorn.inngest")
logger.setLevel(logging.DEBUG)

inngest_client = inngest.Inngest(app_id="fast_api_example", logger=logger)
14 changes: 14 additions & 0 deletions examples/fast_api/src/inngest/functions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import inngest

from .client import inngest_client


@inngest_client.create_function(
fn_id="hello-world",
trigger=inngest.TriggerEvent(event="say-hello"),
)
async def hello(
ctx: inngest.Context,
step: inngest.Step,
) -> str:
return "Hello world!"
12 changes: 5 additions & 7 deletions examples/flask/app.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
import flask
from src.inngest import inngest_client
from src.flask import app
from src.inngest.client import inngest_client
from src.inngest.functions import hello

import inngest.flask
from examples import functions

app = flask.Flask(__name__)


inngest.flask.serve(
app,
inngest_client,
functions.create_sync_functions(inngest_client),
[hello],
)

app.run(port=8000)
3 changes: 3 additions & 0 deletions examples/flask/src/flask.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import flask

app = flask.Flask("my-app")
3 changes: 0 additions & 3 deletions examples/flask/src/inngest/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +0,0 @@
from .client import inngest_client

__all__ = ["inngest_client"]
4 changes: 2 additions & 2 deletions examples/flask/src/inngest/client.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import logging

import inngest
from src.flask import app

logger = logging.getLogger(__name__)
logger.addHandler(logging.StreamHandler())
logger = logging.getLogger(f"{app.logger.name}.inngest")
logger.setLevel(logging.DEBUG)

inngest_client = inngest.Inngest(app_id="flask_example", logger=logger)
14 changes: 14 additions & 0 deletions examples/flask/src/inngest/functions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import inngest

from .client import inngest_client


@inngest_client.create_function(
fn_id="hello-world",
trigger=inngest.TriggerEvent(event="say-hello"),
)
def hello(
ctx: inngest.Context,
step: inngest.StepSync,
) -> str:
return "Hello world!"
50 changes: 0 additions & 50 deletions examples/functions/__init__.py

This file was deleted.

24 changes: 0 additions & 24 deletions examples/functions/batch.py

This file was deleted.

18 changes: 0 additions & 18 deletions examples/functions/cancel.py

This file was deleted.

38 changes: 0 additions & 38 deletions examples/functions/cron.py

This file was deleted.

Loading

0 comments on commit 37f40af

Please sign in to comment.