Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Table name prefixing and fixed typos #208

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions director/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import enum
import uuid
import os

from sqlalchemy_utils import UUIDType

Expand All @@ -10,6 +11,9 @@ def get_uuid():
return str(uuid.uuid4())


DB_TABLE_PREFIX = os.getenv("DIRECTOR_DATABASE_TABLE_PREFIX", "")


class StatusType(enum.Enum):
pending = "pending"
progress = "progress"
Expand Down
4 changes: 2 additions & 2 deletions director/models/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
from sqlalchemy.types import PickleType

from director.extensions import db
from director.models import BaseModel, StatusType
from director.models import BaseModel, StatusType, DB_TABLE_PREFIX
from director.models.utils import JSONBType


class Task(BaseModel):
__tablename__ = "tasks"
__tablename__ = f"{DB_TABLE_PREFIX}tasks"

key = db.Column(db.String(255), nullable=False)
status = db.Column(db.Enum(StatusType), default=StatusType.pending, nullable=False)
Expand Down
4 changes: 2 additions & 2 deletions director/models/users.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@

from director.extensions import db
from director.exceptions import UserNotFound
from director.models import BaseModel, StatusType
from director.models import BaseModel, StatusType, DB_TABLE_PREFIX
from director.models.utils import JSONBType


class User(BaseModel):
__tablename__ = "users"
__tablename__ = f"{DB_TABLE_PREFIX}users"

username = db.Column(db.String(255), unique=True, nullable=False)
password = db.Column(db.String(255), nullable=False)
Expand Down
4 changes: 2 additions & 2 deletions director/models/workflows.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
from director.extensions import db
from director.models import BaseModel, StatusType
from director.models import BaseModel, StatusType, DB_TABLE_PREFIX
from director.models.utils import JSONBType


class Workflow(BaseModel):
__tablename__ = "workflows"
__tablename__ = f"{DB_TABLE_PREFIX}workflows"

name = db.Column(db.String(255), nullable=False)
project = db.Column(db.String(255), nullable=False)
Expand Down
2 changes: 2 additions & 0 deletions director/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"DIRECTOR_FLOWER_URL",
"DIRECTOR_DATABASE_URI",
"DIRECTOR_DATABASE_POOL_RECYCLE",
"DIRECTOR_DATABASE_TABLE_PREFIX",
"DIRECTOR_BROKER_URI",
"DIRECTOR_RESULT_BACKEND_URI",
"DIRECTOR_SENTRY_DSN",
Expand Down Expand Up @@ -60,6 +61,7 @@ def __init__(self, home_path=None, config_path=None):
self.SQLALCHEMY_ENGINE_OPTIONS = {
"pool_recycle": env.int("DIRECTOR_DATABASE_POOL_RECYCLE", -1),
}
self.DB_TABLE_PREFIX = env.str("DIRECTOR_DATABASE_TABLE_PREFIX", "")

# Celery configuration
self.CELERY_CONF = {
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## **GET** `/api/workflows`

List the workflows instances.
List the workflow instances.

**Example request:**

Expand Down
6 changes: 3 additions & 3 deletions docs/docs/guides/enable-authentication.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Enable authentication

Director provide basic authentication. To enable it, you have to create users and set `DIRECTOR_AUTH_ENABLED` variable to **true** in the `.env` file.
Director provides basic authentication. To enable it, you have to create users and set `DIRECTOR_AUTH_ENABLED` variable to **true** in the `.env` file.

## Manage user
## Manage users

You can manage users using the CLI.

Expand All @@ -14,4 +14,4 @@ Create user example:

```bash
$ director user create john
```
```
8 changes: 4 additions & 4 deletions docs/docs/guides/use-payload.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ $ curl --header "Content-Type: application/json" \

## Handle payload

You can handle the payload in the code using the **kwargs** dictionnary :
You can handle the payload in the code using the **kwargs** dictionary :

```python
@task(name="ORDER_PRODUCT")
Expand All @@ -63,7 +63,7 @@ your workflow.

## Create the schema

The previous example executes the workflow without validate its payload. Director
The previous example executes the workflow without validating its payload. Director
provides a way to validate it using [JsonSchema](https://json-schema.org/understanding-json-schema/).

Your schema needs to be stored in a `schemas` folder inside your `DIRECTOR_HOME` (you have to create
Expand Down Expand Up @@ -92,7 +92,7 @@ product.ORDER:
```

!!! tip
You can host your schemas into subfolders (ie `$DIRECTOR_HOME/schemas/foo/bar/baz.json`)
You can host your schemas into subfolders (i.e. `$DIRECTOR_HOME/schemas/foo/bar/baz.json`)
and reference it in your YAML file with : `schema: foo/bar/baz`.

From now the execution will be blocked if the payload is not valid :
Expand Down Expand Up @@ -133,7 +133,7 @@ def update_cache(*args, **kwargs):
return update_user(user)
```

This way the whole list of users will be updated every hours, and a manual update
This way the whole list of users will be updated every hour, and a manual update
can be done on a specific user :

```
Expand Down