fractal-analytics-platform / fractal-web

Web client for Fractal
https://fractal-analytics-platform.github.io/fractal-web/
BSD 3-Clause "New" or "Revised" License
6 stars 0 forks source link

Added Custom Python env task collection #523

Closed zonia3000 closed 2 months ago

zonia3000 commented 2 months ago

Checklist before merging

Closes #517

zonia3000 commented 2 months ago

The new form with the warning message:

image

tcompa commented 2 months ago

Very minor details:

  1. Replace "task" with "tasks" in "Collect the task with regular Fractal" (in warning message)
  2. In the description of the source attribute, I think we should not suggest such a complex example (see reasoning in https://github.com/fractal-analytics-platform/fractal-web/issues/517#issuecomment-2210536532). If we still want to include an example, then the message could read something like

A common label identifying this package (e.g. if you set this to "mypackage" then tasks will have source like "myusername:mypackage:task_module_name").

tcompa commented 2 months ago

I hit what seems like a glitch in the UI for the new endpoint.

How to reproduce

  1. Prepare a form body where python interpreter is non-absolute, manifest is valid, and source is valid.
  2. Click collect -> observe the error (all as expected). The error is shown just below the form field.
  3. Without refreshing, make the python interpreter absolute.
  4. Click collect -> observe the error (all as expected, because either package_name or package_root must be provided). The error is shown below the form.
  5. Without refreshing, set package_name to something
  6. Click collect -> nothing happens but I see an error in the browser console
    Uncaught (in promise) SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data
    handleCollect CustomEnvTask.svelte:110
    AsyncFunctionThrow self-hosted:803
    (Async: async)
    prevent_default index.mjs:432
    (Async: EventListener.handleEvent)
    listen index.mjs:425
    listen_dev index.mjs:2282
    mount CustomEnvTask.svelte:868
    m svelte-hooks.js:291
    mount_component index.mjs:2054
    mount +page.svelte:76
    update +page.svelte:947
    update index.mjs:1298
    flush index.mjs:1258
    (Async: promise callback)
    schedule_update index.mjs:1209
    make_dirty index.mjs:2090
    ctx index.mjs:2128
    input3_change_handler +page.svelte:1132
    (Async: EventListener.handleEvent)
    listen index.mjs:425
    listen_dev index.mjs:2282
    mount +page.svelte:895
    m svelte-hooks.js:291
    mount_component index.mjs:2054
    mount root.svelte:266
    mount root.svelte:548
    mount +layout.svelte:1186
    m svelte-hooks.js:291
    mount_component index.mjs:2054
    mount root.svelte:168
    mount root.svelte:744
    mount_component index.mjs:2054
    init index.mjs:2152
    Root root.svelte:1000
    createProxiedComponent svelte-hooks.js:341
    ProxyComponent proxy.js:242
    Proxy<Root> proxy.js:349
    initialize client.js:304
    _hydrate client.js:1849
    InterpretGeneratorResume self-hosted:1412
    AsyncFunctionNext self-hosted:799
    (Async: async)
    start start.js:22
    <anonymous> tasks:2927
    (Async: promise callback)
    <anonymous> tasks:2926

    while logs of backend and frontend don't show anything specially relevant.

Here is a screenshot of the final state: image

zonia3000 commented 2 months ago

The JSON parse error happens because there is an Internal Server Error on the backend and it doesn't return a JSON response. This happens when the Python Intepreter is set to a not existing file.

I've the following error in backend:

Traceback (most recent call last):
  File "/home/xonya/code/fractal-server/venv/lib/python3.10/site-packages/uvicorn/protocols/http/h11_impl.py", line 407, in run_asgi
    result = await app(  # type: ignore[func-returns-value]
  File "/home/xonya/code/fractal-server/venv/lib/python3.10/site-packages/uvicorn/middleware/proxy_headers.py", line 69, in __call__
    return await self.app(scope, receive, send)
  File "/home/xonya/code/fractal-server/venv/lib/python3.10/site-packages/fastapi/applications.py", line 1054, in __call__
    await super().__call__(scope, receive, send)
  File "/home/xonya/code/fractal-server/venv/lib/python3.10/site-packages/starlette/applications.py", line 123, in __call__
    await self.middleware_stack(scope, receive, send)
  File "/home/xonya/code/fractal-server/venv/lib/python3.10/site-packages/starlette/middleware/errors.py", line 186, in __call__
    raise exc
  File "/home/xonya/code/fractal-server/venv/lib/python3.10/site-packages/starlette/middleware/errors.py", line 164, in __call__
    await self.app(scope, receive, _send)
  File "/home/xonya/code/fractal-server/venv/lib/python3.10/site-packages/starlette/middleware/exceptions.py", line 65, in __call__
    await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send)
  File "/home/xonya/code/fractal-server/venv/lib/python3.10/site-packages/starlette/_exception_handler.py", line 64, in wrapped_app
    raise exc
  File "/home/xonya/code/fractal-server/venv/lib/python3.10/site-packages/starlette/_exception_handler.py", line 53, in wrapped_app
    await app(scope, receive, sender)
  File "/home/xonya/code/fractal-server/venv/lib/python3.10/site-packages/starlette/routing.py", line 756, in __call__
    await self.middleware_stack(scope, receive, send)
  File "/home/xonya/code/fractal-server/venv/lib/python3.10/site-packages/starlette/routing.py", line 776, in app
    await route.handle(scope, receive, send)
  File "/home/xonya/code/fractal-server/venv/lib/python3.10/site-packages/starlette/routing.py", line 297, in handle
    await self.app(scope, receive, send)
  File "/home/xonya/code/fractal-server/venv/lib/python3.10/site-packages/starlette/routing.py", line 77, in app
    await wrap_app_handling_exceptions(app, request)(scope, receive, send)
  File "/home/xonya/code/fractal-server/venv/lib/python3.10/site-packages/starlette/_exception_handler.py", line 64, in wrapped_app
    raise exc
  File "/home/xonya/code/fractal-server/venv/lib/python3.10/site-packages/starlette/_exception_handler.py", line 53, in wrapped_app
    await app(scope, receive, sender)
  File "/home/xonya/code/fractal-server/venv/lib/python3.10/site-packages/starlette/routing.py", line 72, in app
    response = await func(request)
  File "/home/xonya/code/fractal-server/venv/lib/python3.10/site-packages/fastapi/routing.py", line 278, in app
    raw_response = await run_endpoint_function(
  File "/home/xonya/code/fractal-server/venv/lib/python3.10/site-packages/fastapi/routing.py", line 191, in run_endpoint_function
    return await dependant.call(**values)
  File "/home/xonya/code/fractal-server/fractal_server/app/routes/api/v2/task_collection_custom.py", line 66, in collect_task_custom
    res = subprocess.run(  # nosec
  File "/usr/lib/python3.10/subprocess.py", line 503, in run
    with Popen(*popenargs, **kwargs) as process:
  File "/usr/lib/python3.10/subprocess.py", line 971, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "/usr/lib/python3.10/subprocess.py", line 1863, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: '/foo'