DAP Client temp folder and running on AWS Lambda

ColinMurtaugh
Community Champion

Hi --

I'm trying to run my DAP init/sync process in AWS Lambda which does not have a writable filesystem by default. This had been working fine as of DAP Client version 0.3.15, but more recent versions (including the current 0.3.18) give me an error, presumably because the library tries to create a "instructure_dap_temp" temporary directory which fails:

{
  "errorMessage": "[Errno 2] No such file or directory: 'instructure_dap_temp'",
  "errorType": "FileNotFoundError",
  "requestId": "229de7b3-d0c2-4615-a4cd-5348373e3857",
  "stackTrace": [
    "  File \"/var/task/app.py\", line 55, in lambda_handler\n    asyncio.get_event_loop().run_until_complete(\n",
    "  File \"/var/lang/lib/python3.11/asyncio/base_events.py\", line 653, in run_until_complete\n    return future.result()\n",
    "  File \"/var/task/dap/actions/sync_db.py\", line 16, in sync_db\n    await SQLReplicator(session, db_connection).synchronize(\n",
    "  File \"/var/task/dap/replicator/sql.py\", line 120, in synchronize\n    await client.download(\n",
    "  File \"/var/task/dap/downloader.py\", line 192, in download\n    with use_and_remove(DEFAULT_FOLDER) as directory:\n",
    "  File \"/var/lang/lib/python3.11/contextlib.py\", line 155, in __exit__\n    self.gen.throw(typ, value, traceback)\n",
    "  File \"/var/task/dap/downloader.py\", line 39, in use_and_remove\n    rmtree(directory)\n",
    "  File \"/var/lang/lib/python3.11/shutil.py\", line 722, in rmtree\n    onerror(os.lstat, path, sys.exc_info())\n",
    "  File \"/var/lang/lib/python3.11/shutil.py\", line 720, in rmtree\n    orig_st = os.lstat(path, dir_fd=dir_fd)\n"
  ]
}

In Lambda I can provide a read/write filesystem, but it must be mounted at a path under /mnt/. So -- my request is: in a future version of the DAP Client, could the location of that "instructure_dap_temp" folder be overridable? In theory that would let me place it on the read/write filesystem and things should work as before. 

That value is set at line 26 of downloader.py:

DEFAULT_FOLDER: str = "instructure_dap_temp"

I'd like a clean way to be able to set that to "/mnt/instructure_dap_temp" or something similar. 

cc: @LeventeHunyadi 

Thanks!

--Colin 

Labels (2)