Skip to main content

A UI for darq

Project description

UI for darq async task manager - https://github.com/seedofjoy/darq

Darq UI

Installation

pip install darq-ui

Or with extra dependencies:

pip install darq-ui[aiohttp]
# or
pip install darq-ui[fastapi]

Integration

Use setup function like this from darq_ui.integration.<framework> import setup to integrate darq-ui with your application.

For example, to integrate with FastAPI:

from fastapi import FastAPI
from darq.app import Darq
from darq_ui.integration.fastapi import setup

app = FastAPI()
darq = Darq()

setup(app, darq)

Web UI

Once you have your server running, you can access the web UI at http://host:port/darq.

You can pass the base_path parameter to the setup function in order to change the base path of the UI.

setup(app, darq, base_path="/my-path")

You can disable the web UI by passing web_ui=False to the setup function (it can be usefull if you want to embed darq_ui and use it only that way).

### Embeding

If you already have a UI (admin UI for example) and you can embed darq-ui into it.

```python
setup(app, darq, base_path="/admin/darq", embed=True)

embed=True will enable special endpoint /admin/darq/embed (if you set base_path="/admin/darq").

Then you can use it in an iframe:

export const Tasks = () => {
  const url = "http://localhost:3000/admin/darq/embed";
  return <iframe title='Darq UI' style={{ border: '0px' }} src={url} height='100%' width='100%' />;
}

Logging link

If you have a logging system (kibana for example), you can pass logs_url to setup function. One requirement is that the url should have the ${taskName} placeholder which will be replaced with the task name.

setup(app, darq, logs_url="https://mylogserver.com/taskname=${taskName}")

Kibana url example

If you have kibana, you can use the following url:

https://kibana.corp/app/discover#/?_g=(time:(from:now-15m,to:now))&_a=(filters:!((('$state':(store:appState),meta:(key:task_name,params:(query:'%22${taskName}%22')),query:(match_phrase:(task_name:’${taskName}')))))

In this url, task_name is a field name and ${taskName} will be replaced with the task name value. (This is just an example. You may need to adjust it according to your kibana configuration.)

Securing the UI

Since darq-ui is a part of your application, and can run any task, you should consider protecting it with authorization middleware or firewall.

Examples

In order to run examples you need to install the dependencies:

cd examples
pdm install

And then run the server from the repo root:

lets run-fastapi 
# or 
lets run-aiohttp

Development

Run client build

In root directory:

lets build-ui

This will build production version of assets and copy them to src/darq_ui/static directory.

lets build-ui-dev

This will build and watch development version of assets and copy them to src/darq_ui/static directory.

Now you can run the server and it will serve the UI from the src/darq_ui/static directory.

lets run-fastapi

Run linters, formatters and other checks

pdm run ruff
pdm run ruff-fmt
pdm run mypy

Changelog

When developing, add notes to CHANGELOG.md to Unreleased section.

After we decided to release new version, we must rename Unreleased to new tag version and add new Unreleased section.

Publishing

darq-ui supports semver versioning.

  • Update the version number in the src/darq_ui/__init__.py file.
  • Update the changelog in the CHANGELOG.md file.
  • Merge changes into master.
  • Create a tag git tag -a v0.0.X -m 'your tag message'.
  • Push the tag git push origin --tags.

All of the above steps can be done with the following command:

lets release <version> -m 'your release message'

When new tag pushed, new release action on GitHub will publish new package to pypi.

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

darq_ui-0.0.1.tar.gz (326.1 kB view details)

Uploaded Source

Built Distribution

darq_ui-0.0.1-py3-none-any.whl (327.5 kB view details)

Uploaded Python 3

File details

Details for the file darq_ui-0.0.1.tar.gz.

File metadata

  • Download URL: darq_ui-0.0.1.tar.gz
  • Upload date:
  • Size: 326.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: pdm/2.19.1 CPython/3.10.15 Linux/6.5.0-1025-azure

File hashes

Hashes for darq_ui-0.0.1.tar.gz
Algorithm Hash digest
SHA256 c00ba7d25d38a7f037c1c54eccfbf228901aab3f18de102e258fd10ab1c3d8de
MD5 0e12a61a530fe3c3f18462e0863b9c7e
BLAKE2b-256 b2517286297274b5a8c1677020bd4cf7e50b2f85e73dfdce77a1b3b47412b4c4

See more details on using hashes here.

File details

Details for the file darq_ui-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: darq_ui-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 327.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: pdm/2.19.1 CPython/3.10.15 Linux/6.5.0-1025-azure

File hashes

Hashes for darq_ui-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 bdf272a32d2ce91adcc9fd41f012361ac0721287c5375bdbaadb2d25ebbafe70
MD5 20c9fd3f7b5293d19b70585be73d66c3
BLAKE2b-256 99b1c4f180f5f88b7e9ef13596dba66d2557aa434ca6fca46db438a5809caf22

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