Skip to content

Commit

Permalink
chore(release): 0.0.18a10
Browse files Browse the repository at this point in the history
  • Loading branch information
Alw3ys committed Feb 11, 2024
1 parent 6945a4a commit a15140b
Show file tree
Hide file tree
Showing 16 changed files with 57 additions and 147 deletions.
24 changes: 13 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
# Dosei Python SDK

`dosei` is the official Dosei SDK for Python
`dosei-sdk` is the official Dosei SDK for Python

[![pypi version](https://img.shields.io/pypi/v/dosei.svg)](https://pypi.org/pypi/dosei/)
[![Downloads](https://static.pepy.tech/badge/dosei/week)](https://pypi.org/pypi/dosei/)
[![License: MIT](https://img.shields.io/badge/license-Apache--2.0-yellow)](https://www.apache.org/licenses/LICENSE-2.0)
[![Twitter](https://img.shields.io/twitter/url/https/x.com/dosei_ai.svg?style=social&label=Follow%20%40dosei_ai)](https://x.com/dosei_ai)
[![](https://dcbadge.vercel.app/api/server/BP5aUkhcAh?compact=true&style=flat)](https://discord.com/invite/BP5aUkhcAh)
[![](https://img.shields.io/discord/1144175748559683615?logo=discord&logoColor=7289DA&label=Discord)](https://discord.com/invite/BP5aUkhcAh)
[![X (formerly Twitter)](https://img.shields.io/twitter/follow/dosei_ai?style=flat&logo=x)](https://x.com/dosei_ai)
[![License: Apache-2.0](https://img.shields.io/badge/license-Apache--2.0-white)](https://www.apache.org/licenses/LICENSE-2.0)


## Getting Started
Expand All @@ -15,17 +14,20 @@
- [Python 3.11.2](https://www.python.org/downloads/)

### Install
You can install and configure `dosei` using this command:
You can install and configure `dosei-sdk` using this command:

```bash
pip install -U dosei
pip install -U dosei-sdk
```

### Configure

```python
from fastapi import FastAPI
import dosei.integrations.fastapi as dosei_fastapi_integration
from dosei_sdk import Dosei

dosei = Dosei()

app = FastAPI()
dosei_fastapi_integration.init(app)
@dosei.cron_job("* * * * *")
def cron_job():
print("hello world!")
```
1 change: 0 additions & 1 deletion dosei/__init__.py

This file was deleted.

Empty file removed dosei/integrations/__init__.py
Empty file.
42 changes: 0 additions & 42 deletions dosei/integrations/fastapi.py

This file was deleted.

40 changes: 0 additions & 40 deletions dosei/main.py

This file was deleted.

1 change: 1 addition & 0 deletions dosei_sdk/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from dosei_sdk.app import Dosei
3 changes: 1 addition & 2 deletions dosei/app.py → dosei_sdk/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ class Dosei(BaseModel):
_app_export_path: str = ".dosei/app.json"

name: Optional[str] = None
command: Optional[str] = None
dev: Optional[str] = None
run: Optional[str] = None
port: Optional[int] = None
cron_jobs: Optional[List[CronJob]] = []

Expand Down
File renamed without changes.
30 changes: 30 additions & 0 deletions dosei_sdk/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import os
import sys

from dosei_sdk import Dosei
from dosei_sdk.importer import import_from_string, ImportFromStringError

dosei_init = "dosei:dosei"

# Add current dir to PYTHONPATH
sys.path.insert(0, "")


def run(func):
if func:
return Dosei.call_func(import_from_string(func))
try:
app: Dosei = import_from_string(dosei_init)
except ImportFromStringError:
raise ImportFromStringError(f"Couldn't find a dosei.py file in \"{os.getcwd()}\"")
if app.command is None:
raise ImportFromStringError('Command "run" not found.')
os.system(app.run)


def export():
try:
app: Dosei = import_from_string(dosei_init)
return app.export()
except ImportFromStringError:
raise ImportFromStringError(f"Couldn't find a dosei.py file in \"{os.getcwd()}\"")
File renamed without changes.
11 changes: 4 additions & 7 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,23 +1,20 @@
[tool.poetry]
name = "dosei"
version = "0.0.18a9"
name = "dosei-sdk"
version = "0.0.18a10"
description = "Dosei Python SDK"
authors = ["Alvaro Molina <[email protected]>"]
license = "Apache-2.0"
readme = "README.md"

[tool.poetry.scripts]
dosei = 'dosei.main:cli'

[tool.poetry.dependencies]
python = "^3.11"
fastapi = "^0.109.2"
pytest-trio = "^0.8.0"
croniter = "^2.0.1"
pydantic = "^2.6.1"


[tool.poetry.group.dev.dependencies]
pytest-trio = "^0.8.0"
fastapi = "^0.109.2"
pytest = "^7.4.3"
httpx = "^0.25.0"

Expand Down
2 changes: 1 addition & 1 deletion tests/example_project/main.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from dosei import Dosei
from dosei_sdk import Dosei

dosei = Dosei()

Expand Down
5 changes: 2 additions & 3 deletions tests/fastapi/dosei_config.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import os
from dosei import Dosei
from dosei_sdk import Dosei

port = os.getenv('PORT', 8080)
dosei = Dosei(
name="hello-world",
command=f"uvicorn helloworld.main:app --host 0.0.0.0 --port {port}",
dev=f"uvicorn helloworld.main:app --port {port} --reload",
run=f"uvicorn helloworld.main:app --host 0.0.0.0 --port {port}",
port=port
)
7 changes: 3 additions & 4 deletions tests/fastapi/test_fastapi.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
from dosei import Dosei
from dosei.importer import import_from_string
from dosei_sdk import Dosei
from dosei_sdk.importer import import_from_string


def test_fastapi():
app: Dosei = import_from_string("tests.fastapi.dosei_config:dosei")
assert app.name == "hello-world"
assert app.port == 8080
assert app.command == f"uvicorn helloworld.main:app --host 0.0.0.0 --port {app.port}"
assert app.dev == f"uvicorn helloworld.main:app --port {app.port} --reload"
assert app.run == f"uvicorn helloworld.main:app --host 0.0.0.0 --port {app.port}"
4 changes: 2 additions & 2 deletions tests/test_app.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from dosei import Dosei
from dosei_sdk import Dosei
import pytest

from dosei.importer import import_from_string
from dosei_sdk.importer import import_from_string

dosei = Dosei()

Expand Down
34 changes: 0 additions & 34 deletions tests/test_middleware.py

This file was deleted.

0 comments on commit a15140b

Please sign in to comment.