systemetric / shepherd-2

A rewrite of shepherd
Apache License 2.0
4 stars 0 forks source link

Sheep compatiability #21

Closed shardros closed 2 years ago

shardros commented 2 years ago

This PR will be merged when there is all of the parts which sheep needs to run working.

fenjalien commented 2 years ago

Running this branch on my pi produces this error when the start button is pressed in the editor:

INFO:     127.0.0.1:44546 - "POST /upload/upload HTTP/1.1" 500 Internal Server Error
ERROR:    Exception in ASGI application
Traceback (most recent call last):
  File "/home/pi/.cache/pypoetry/virtualenvs/shepherd-2-TGIJcPDa-py3.10/lib/python3.10/site-packages/uvicorn/protocols/http/h11_impl.py", line 394, in run_asgi
    result = await app(self.scope, self.receive, self.send)
  File "/home/pi/.cache/pypoetry/virtualenvs/shepherd-2-TGIJcPDa-py3.10/lib/python3.10/site-packages/uvicorn/middleware/proxy_headers.py", line 45, in __call__
    return await self.app(scope, receive, send)
  File "/home/pi/.cache/pypoetry/virtualenvs/shepherd-2-TGIJcPDa-py3.10/lib/python3.10/site-packages/fastapi/applications.py", line 199, in __call__
    await super().__call__(scope, receive, send)
  File "/home/pi/.cache/pypoetry/virtualenvs/shepherd-2-TGIJcPDa-py3.10/lib/python3.10/site-packages/starlette/applications.py", line 112, in __call__
    await self.middleware_stack(scope, receive, send)
  File "/home/pi/.cache/pypoetry/virtualenvs/shepherd-2-TGIJcPDa-py3.10/lib/python3.10/site-packages/starlette/middleware/errors.py", line 181, in __call__
    raise exc from None
  File "/home/pi/.cache/pypoetry/virtualenvs/shepherd-2-TGIJcPDa-py3.10/lib/python3.10/site-packages/starlette/middleware/errors.py", line 159, in __call__
    await self.app(scope, receive, _send)
  File "/home/pi/.cache/pypoetry/virtualenvs/shepherd-2-TGIJcPDa-py3.10/lib/python3.10/site-packages/starlette/exceptions.py", line 82, in __call__
    raise exc from None
  File "/home/pi/.cache/pypoetry/virtualenvs/shepherd-2-TGIJcPDa-py3.10/lib/python3.10/site-packages/starlette/exceptions.py", line 71, in __call__
    await self.app(scope, receive, sender)
  File "/home/pi/.cache/pypoetry/virtualenvs/shepherd-2-TGIJcPDa-py3.10/lib/python3.10/site-packages/starlette/routing.py", line 580, in __call__
    await route.handle(scope, receive, send)
  File "/home/pi/.cache/pypoetry/virtualenvs/shepherd-2-TGIJcPDa-py3.10/lib/python3.10/site-packages/starlette/routing.py", line 241, in handle
    await self.app(scope, receive, send)
  File "/home/pi/.cache/pypoetry/virtualenvs/shepherd-2-TGIJcPDa-py3.10/lib/python3.10/site-packages/starlette/routing.py", line 52, in app
    response = await func(request)
  File "/home/pi/.cache/pypoetry/virtualenvs/shepherd-2-TGIJcPDa-py3.10/lib/python3.10/site-packages/fastapi/routing.py", line 216, in app
    raw_response = await run_endpoint_function(
  File "/home/pi/.cache/pypoetry/virtualenvs/shepherd-2-TGIJcPDa-py3.10/lib/python3.10/site-packages/fastapi/routing.py", line 151, in run_endpoint_function
    return await run_in_threadpool(dependant.call, **values)
  File "/home/pi/.cache/pypoetry/virtualenvs/shepherd-2-TGIJcPDa-py3.10/lib/python3.10/site-packages/starlette/concurrency.py", line 40, in run_in_threadpool
    return await loop.run_in_executor(None, func, *args)
  File "/home/pi/.pyenv/versions/3.10.6/lib/python3.10/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/pi/shepherd-2/./app/routers.py", line 55, in upload_file
    app.upload.process_uploaded_file(uploaded_file)
  File "/home/pi/shepherd-2/./app/upload.py", line 110, in process_uploaded_file
    shutil.rmtree(config.round_path)
  File "/home/pi/.pyenv/versions/3.10.6/lib/python3.10/shutil.py", line 714, in rmtree
    onerror(os.lstat, path, sys.exc_info())
  File "/home/pi/.pyenv/versions/3.10.6/lib/python3.10/shutil.py", line 712, in rmtree
    orig_st = os.lstat(path)
FileNotFoundError: [Errno 2] No such file or directory: '/home/pi/shepherd-2/usercode/round'

The later run request gives a 409

INFO:     127.0.0.1:49338 - "POST /run/start HTTP/1.1" 409 Conflict

The output of running pytest is

test/test_editor.py ..                                                             [ 20%]
test/test_home.py .                                                                [ 30%]
test/test_runner.py x..F                                                           [ 70%]
test/test_upload.py FFF                                                            [100%]

It looks like the failures are also due to the directory usercode/round not exsisting, what is the purpose of this folder @shardros ?

shardros commented 2 years ago

Fixed and tested on fresh install

shardros commented 2 years ago

It looks like the failures are also due to the directory usercode/round not exsisting, what is the purpose of this folder @shardros ?

This is correct. This is the folder where the usercode which is to be run in the next round is uploaded to. It is now automatically created by shepherd. Logs aren't done in this pr but you can see that the code works by looking logs.txt

fenjalien commented 2 years ago

This is the folder where the usercode which is to be run in the next round is uploaded to.

Ah so usercode/ is all the code that has been written by the user and usercode/round/ is the code that will be run when /run/start is hit?

shardros commented 2 years ago

This is the folder where the usercode which is to be run in the next round is uploaded to.

Ah so usercode/ is all the code that has been written by the user and usercode/round/ is the code that will be run when /run/start is hit?

Correct :)

fenjalien commented 2 years ago

I've just tried changing this: https://github.com/systemetric/shepherd-2/blob/18c9b5400693804166bce94a13cfecd273b374ea/app/routers.py#L33 to this:

runner.state = States.RUNNING

and all tests pass apart from larg_zip_upload by timeout. I'm assuming this is due to the shear size its timeout will need to be much longer.

shardros commented 2 years ago

@fenjalien ready for another round of review

shardros commented 2 years ago

You can still retroactively do the code review but we need to move fast