bartongroup / slivka

http://bartongroup.github.io/slivka/
Apache License 2.0
7 stars 3 forks source link

`/api/jobs/{job-id}` endpoint throws `TypeError` when run in a VM #146

Open warownia1 opened 2 weeks ago

warownia1 commented 2 weeks ago

/api/jobs/{job-id} endpoint throws TypeError: Object of type PosixPath is not JSON serializable

The file parameter is not converted to a proper relative path if it is a file parameter and the value is an absolute path which is neither relative to the jobs not to the uploads directory. The issue happens when the media directory specified in the settings file is a link to a different location e.g. /home/www-slivka/.../slivka-bio/media/jobs points to the canonical path /cluster/gjb_lab/.../slivka-bio/media/jobs. The value of the parameter becomes relative to the canonical path which is no longer relative to the path specified in the configuration file. The direct cause of the exception is the convert_path(value) method which fails to strip the leading part from the absolute file path.

@stuartmac Patching it is simple, but, if we want to do it properly we need to identify why and when the file path is converted to the absolute path.

EDIT: the issue is not caused by different mount points inside the virtual machine, but symbolic links present in the directory structure.

warownia1 commented 2 weeks ago

Related to issue #129

warownia1 commented 2 weeks ago

The input file path is always converted to the real path when the file is saved by using slivka.server.forms.file_proxy.FileProxy#save_file. I do not remember why is that, but having uploads dir and jobs dir converted to the real path as well during the configuration stage should solve the issue