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

dtale fastapi integration #763

Open
jv1522 opened this issue Jun 5, 2023 · 1 comment
Open

dtale fastapi integration #763

jv1522 opened this issue Jun 5, 2023 · 1 comment

Comments

@jv1522
Copy link

jv1522 commented Jun 5, 2023

Is it possible to integrate dtale with fastapi and send the filters applied on UI back to the API to persist the filters?

@aschonfeld
Copy link
Collaborator

@jv1522 I can look into how hard it will be to convert the non-HTML based endpoints over to FastAPI. It will have to be customized to a point in order to support Python2.

You can currently save filters by hitting the following endpoints this way (this is to filter a string column on a set of values):

import requests
import json

requests.get(
  'http://<dtale_host>:<dtale_port>/dtale/save-column-filter/<dtale_data_id>',
  params={
    'col': '<column_name>',
    'cfg': json.dumps({'type': 'string', 'value': ['b']})
  }
)

To drop this filter you would do the following (the column name would need to match the one used above):

import requests

requests.get(
  'http://<dtale_host>:<dtale_port>/dtale/save-column-filter/<dtale_data_id>',
  params={'col': '<column_name>', 'cfg': None}
)

Here are some sample filter configs for different types of columns:

{"type": "string", "value": ["False"]}  # boolean column equal to False
{"type": "int", "missing": True}. # integer column whose values are NaN
{"type": "float", "missing": True}  # float column whose values are NaN
{"type": "date", "missing": True}  # date column whose values are NaN
{"type": "string", "missing": True}  # string column whose values are NaN

# all these integer filters also apply for float columns as well
{"type": "int", "operand": "=", "value": "5"}  # integer column with values equal to 5 (operands are "=", "<", ">", "<=", ">=", "ne")
{"type": "int", "operand": "=", "value": ["5", "4"]}  # integer column with values equal to 5 or 4
{"type": "int", "operand": "ne", "value": ["5", "4"]}  # integer column with values NOT equal to 5 or 4
{"type": "int", "operand": "[]", "min": "4", "max": "5"}  # integer column >= 4 and <= 5
{"type": "int", "operand": "()", "min": "4", "max": "5"}  # integer column > 4 and < 5
{"type": "int", "operand": "()", "min": "4", "max": None}  # integer column > 4

{"type": "date", "start": "20000101", "end": "20000101"}  # date column equal to 2000-01-01
{"type": "date", "start": "20000101", "end": "20000102"}  # date column between 2000-01-01 and 2000-01-02

{"type": "string", "action": "equals", "operand": "=", "value": ["a", "b"]}  # string column equal to 'a' or 'b'
{"type": "string", "action": "equals", "operand": "ne", "value": ["a", "b"]}  # string column NOT equal to 'a' or 'b'
{"type": "string", "action": "equals", "operand": "=", "value": ["a", "b"], "caseSensitive": True}  # string column equal to 'a' or 'b' w/ case-sensitivity on (this is turned off by default)
{"type": "string", "action": "startswith", "raw": "a"}  # string column starting with 'a' (can be used w/ case-sensitivity)
{"type": "string", "action": "endswith", "raw": "a"}  # string column ending with 'a' (can be used w/ case-sensitivity)
{"type": "string", "action": "contains", "raw": "a"}  # string column containing 'a' (can be used w/ case-sensitivity)
{"type": "string", "action": "regex", "raw": "a"}  # string column filtered by regex 'a' (can be used w/ case-sensitivity)
{"type": "string", "action": "length", "raw": "1,3"}  # string column with values of lengths between 1 and 3 (inclusive)

Hope this gives you enough to get started

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants