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

Release 0.5.9 #91

Merged
merged 6 commits into from
Jul 28, 2024
Merged
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
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -580,10 +580,9 @@ For debugging:
Our table widget uses advanced features in MUI Pro. If you have a MUI Pro license, you can build the frontend with MUI Pro by following the steps below:

1. Install Node.js and Yarn;
2. Create a file called `.env` in the `frontend` folder;
3. Add `MUI_PRO_LICENSE_KEY=[your_key]` to the file;
4. Run `yarn install && yarn funix:build` to build the frontend;
5. Done!
2. Run `export MUI_PRO_LICENSE_KEY=[MUI_KEY]`;
3. Run `yarn install && yarn funix:build` to build the frontend;
4. Done!

### Command line options

Expand Down
7 changes: 3 additions & 4 deletions README.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -586,10 +586,9 @@ def gray_it(image: funix.hint.BytesImage) -> IPython.display.Image:
我们的表格组件可以使用 MUI Pro 中的高级功能。如果你有一个 MUI Pro 的证书许可,你可以使用自己的 MUI Pro 证书并构建前端:

1. 确保安装了 Node.js 和 Yarn;
2. 在 `frontend` 文件夹中创建 `.env` 文件;
3. 添加 `MUI_PRO_LICENSE_KEY=[your_key]` 到你的文件;
4. 运行 `yarn install && yarn funix:build` 构建前端;
5. 万事大吉!
2. 运行 `export MUI_PRO_LICENSE_KEY=[MUI_KEY]`;
3. 运行 `yarn install && yarn funix:build` 构建前端;
4. 万事大吉!

### 命令行选项

Expand Down
2 changes: 1 addition & 1 deletion backend/funix/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def cli_main():

This function is called when you run `python -m funix` or `funix` from the command line.
"""
plac.call(main, version="Funix 0.5.8")
plac.call(main, version="Funix 0.5.9")


if __name__ == "__main__":
Expand Down
4 changes: 2 additions & 2 deletions backend/funix/build/asset-manifest.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"files": {
"main.css": "/static/css/main.4efb37a3.css",
"main.js": "/static/js/main.279c7e85.js",
"main.js": "/static/js/main.ff2fb548.js",
"index.html": "/index.html"
},
"entrypoints": [
"static/css/main.4efb37a3.css",
"static/js/main.279c7e85.js"
"static/js/main.ff2fb548.js"
]
}
2 changes: 1 addition & 1 deletion backend/funix/build/index.html
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<!doctype html><html lang="en"><head><meta charset="utf-8"/><link rel="icon" href="/favicon.ico"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="description" content="Textea Funix React Frontend"/><link rel="apple-touch-icon" href="/logo192.png"/><link rel="manifest" href="/manifest.json"/><link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,700&display=swap"/><script src="static/js/d3.v5.js"></script><script src="static/js/mpld3.v0.5.8.js"></script><script src="static/js/jquery-3.7.1.min.js"></script><style>.text-style{margin:0;padding:0;list-style-position:inside}</style><title>Funix</title><script defer="defer" src="/static/js/main.279c7e85.js"></script><link href="/static/css/main.4efb37a3.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div></body></html>
<!doctype html><html lang="en"><head><meta charset="utf-8"/><link rel="icon" href="/favicon.ico"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="description" content="Textea Funix React Frontend"/><link rel="apple-touch-icon" href="/logo192.png"/><link rel="manifest" href="/manifest.json"/><link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,700&display=swap"/><script src="static/js/d3.v5.js"></script><script src="static/js/mpld3.v0.5.8.js"></script><script src="static/js/jquery-3.7.1.min.js"></script><style>.text-style{margin:0;padding:0;list-style-position:inside}</style><title>Funix</title><script defer="defer" src="/static/js/main.ff2fb548.js"></script><link href="/static/css/main.4efb37a3.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div></body></html>
2 changes: 0 additions & 2 deletions backend/funix/build/static/js/main.279c7e85.js

This file was deleted.

2 changes: 2 additions & 0 deletions backend/funix/build/static/js/main.ff2fb548.js

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ PERFORMANCE OF THIS SOFTWARE.
*/

/**
* @mui/styled-engine v5.15.9
* @mui/styled-engine v5.14.7
*
* @license MIT
* This source code is licensed under the MIT license found in the
Expand Down
14 changes: 12 additions & 2 deletions backend/funix/decorator/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,8 @@ def object_is_handled(app_: Flask, object_id: int) -> bool:
P = ParamSpec("P")
R = TypeVar("R")

RateLimiter = Union[Limiter, list['RateLimiter'], dict[str, 'RateLimiter'], None]
RateLimiter = Union[Limiter, list["RateLimiter"], dict[str, "RateLimiter"], None]


def funix(
path: Optional[str] = None,
Expand Down Expand Up @@ -493,6 +494,8 @@ def _function_reactive_update():

decorated_params = {}
json_schema_props = {}
param_widget_whitelist_callable = {}
param_widget_example_callable = {}

cast_to_list_flag, return_type_parsed = parse_function_annotation(
function_signature, figure_to_image
Expand Down Expand Up @@ -521,6 +524,8 @@ def _function_reactive_update():
treat_as,
examples,
whitelist,
param_widget_whitelist_callable,
param_widget_example_callable,
)

if function_docstring_parsed is not None:
Expand Down Expand Up @@ -631,7 +636,12 @@ def decorated_function_param_getter():
flask.Response: The function's parameters
"""
return get_param_for_funix(
app_.name, pre_fill, decorated_function, session_description
app_.name,
pre_fill,
decorated_function,
session_description,
param_widget_whitelist_callable,
param_widget_example_callable,
)

decorated_function_param_getter_name = f"{function_name}_param_getter"
Expand Down
5 changes: 3 additions & 2 deletions backend/funix/decorator/call.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,9 @@ def funix_call(
big_dict = {}
get_args = dataframe_metadata[need_argument]
for get_arg in get_args:
big_dict[get_arg] = deepcopy(function_kwargs[get_arg])
del function_kwargs[get_arg]
if get_arg in function_kwargs:
big_dict[get_arg] = deepcopy(function_kwargs[get_arg])
del function_kwargs[get_arg]
function_kwargs[need_argument] = pandas_module.DataFrame(big_dict)
if function_id in get_parse_type_metadata():
for func_arg, func_arg_type_class in get_parse_type_metadata()[
Expand Down
20 changes: 20 additions & 0 deletions backend/funix/decorator/param.py
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,8 @@ def get_param_for_funix(
pre_fill: dict | None,
decorated_function: dict,
session_description: str,
param_widget_whitelist_callable: dict,
param_widget_example_callable: dict,
):
new_decorated_function = deepcopy(decorated_function)
if pre_fill is not None:
Expand All @@ -330,6 +332,24 @@ def get_param_for_funix(
new_decorated_function["schema"]["properties"][argument_key][
"default"
] = last_result
if param_widget_whitelist_callable:
for (
whitelist_,
whitelist_value_callable,
) in param_widget_whitelist_callable.items():
whitelist_value = whitelist_value_callable()
new_decorated_function["params"][whitelist_]["whitelist"] = whitelist_value
new_decorated_function["schema"]["properties"][whitelist_][
"whitelist"
] = whitelist_value

if param_widget_example_callable:
for example_, example_value_callable in param_widget_example_callable.items():
example_value = example_value_callable()
new_decorated_function["params"][example_]["example"] = example_value
new_decorated_function["schema"]["properties"][example_][
"example"
] = example_value
if session_description:
des = get_global_variable(session_description)
new_decorated_function["description"] = des
Expand Down
11 changes: 11 additions & 0 deletions backend/funix/decorator/widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,8 @@ def widget_parse(
treat_as: dict,
examples: dict,
whitelist: dict,
param_widget_whitelist_callable: dict,
param_widget_example_callable: dict,
):
function_params_name: list[str] = list(function_params.keys())

Expand All @@ -235,6 +237,15 @@ def widget_parse(
function_name,
i[2],
)
if examples:
for example, example_value in examples.items():
if callable(example_value):
param_widget_example_callable[example] = example_value

if whitelist:
for whitelist_, whitelist_value in whitelist.items():
if callable(whitelist_value):
param_widget_whitelist_callable[whitelist_] = whitelist_value


def parse_argument_config(
Expand Down
10 changes: 7 additions & 3 deletions backend/funix/hint/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,13 +97,14 @@
{("a", "b"): "cell"} -> The parameter `a` and `b` are cells.
"""

WhitelistValues = list[list[str]] | list[str]
WhitelistValues = list[list[str]] | list[str] | Callable[..., Any]
"""
The value of the `whitelist`.

Types:
list[list]: The whitelist, for example: [["a", "b"], ["c", "d"]].
list: The whitelist, for example: ["a", "b"].
function: return a list of values.
"""

WhitelistType = Optional[dict[Parameters, WhitelistValues]]
Expand All @@ -116,13 +117,14 @@
`["a", "b"]`, for `b` the whitelist is `["c", "d"]`.
"""

ExamplesValues = list[list[str]] | list[str]
ExamplesValues = list[list[str]] | list[str] | Callable[..., Any]
"""
The value of the `examples`.

Types:
list[list]: The examples, for example: [["a", "b"], ["c", "d"]].
list: The examples, for example: ["a", "b"].
function: return a list of values.
"""

ExamplesType = Optional[dict[Parameters, ExamplesValues]]
Expand Down Expand Up @@ -245,7 +247,9 @@ class ConditionalVisible(TypedDict):

PreFillEmpty = TypeVar("PreFillEmpty")

ReactiveType = Optional[dict[str, Callable[..., Any] | tuple[Callable[..., Any], dict[str, str]]]]
ReactiveType = Optional[
dict[str, Callable[..., Any] | tuple[Callable[..., Any], dict[str, str]]]
]
"""
Document is on the way
"""
Expand Down
6 changes: 5 additions & 1 deletion backend/funix/util/module.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,11 @@ def handle_module(
is_cls = isclass(module_member)
if is_func or is_cls:
if getsourcefile_safe(module_member) != module.__file__:
continue
if hasattr(module_member, "__wrapped__"):
if getsourcefile_safe(module_member.__wrapped__) != module.__file__:
continue
else:
continue
in_funix = (
decorator.object_is_handled(app, id(module_member))
or id(module_member) in hint.custom_cls_ids
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,8 @@ const ObjectFieldExtendedTemplate = (props: ObjectFieldProps) => {
Column Preview
</Typography>
<DataGrid
pagination
autoPageSize
columns={[{ field: elementProps.name, minWidth: 350 }]}
rows={candidateRows}
sx={{ minHeight: 400 }}
Expand Down Expand Up @@ -956,6 +958,8 @@ const ObjectFieldExtendedTemplate = (props: ObjectFieldProps) => {
</Stack>
<Box sx={{ height: 400, mt: 1, paddingRight: 1 }}>
<DataGrid
pagination
autoPageSize
columns={columns}
columnVisibilityModel={{
id: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ export default function OutputDataframe(props: {
return (
<Box sx={{ height: 400, width: "100%" }}>
<DataGrid
pagination
autoPageSize
rows={newDataframe}
columns={columns}
components={{
Expand Down
4 changes: 4 additions & 0 deletions frontend/src/components/FunixFunction/OutputPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,8 @@ const OutputPanel = (props: {
else if (props.selectedResponseViewType === "sheet")
return (
<DataGrid
pagination
autoPageSize
columns={[
{ field: "id", headerName: "ID" },
{ field: "value", headerName: "Root" },
Expand Down Expand Up @@ -174,6 +176,8 @@ const OutputPanel = (props: {
}
const grid = (
<DataGrid
pagination
autoPageSize
columns={keysOfArraysInSheet.map((key) => ({
field: key,
}))}
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "funix"
version = "0.5.8"
version = "0.5.9"
authors = [
{name = "Textea Inc.", email = "forrestbao@gmail.com"}
]
Expand Down
Loading