jamalex / notion-py

Unofficial Python API client for Notion.so
MIT License
4.29k stars 474 forks source link

os.makedirs not callable on aws lambda #20

Closed EvanFarrell closed 5 years ago

EvanFarrell commented 5 years ago

on write-only containers (with temp dirs) like lambda instances, DATADIR and the likes should be created in tmp/<path>. I don't see much downside in doing this in all cases. will be forking for my own purposes, lmk if I should open a PR

jamalex commented 5 years ago

One of the original purposes of the DATA_DIR is to have a local cache saved, essentially as a backup, and also for efficiency. Since it's specifically for continuity across runs of the library, I wouldn't want to randomly generate a new directory under /tmp each time, but it could easily be configured to use a specific directory under /tmp if desired.

It pulls from an environment variable, so you could probably get away with just setting that, instead of forking? DATA_DIR = os.environ.get("NOTION_DATA_DIR", str(Path(os.path.expanduser("~")).joinpath(".notion-py")))

If that doesn't meet your need, would love to see a PR in case it's useful to others!

EvanFarrell commented 5 years ago

nice! I'll do this, ty

stephensilber commented 5 years ago

@EvanFarrell Did you ever get this library to run on AWS lamda? I have set the ENV to use /tmp/... but run into other issues that seem to be caused by Lock from multiprocessing

EvanFarrell commented 5 years ago

@stephensilber Yeah I couldn't get around the Lock problem, I ended up spinning up a heroku instance

stephensilber commented 5 years ago

@EvanFarrell I ended up getting it to run really easily on a Google Cloud Compute Function (which is free for the first 2 million calls in a month I believe). I was even able to set up a free Google Cloud scheduler task to run every 1 minute for one of my other notion scripts

cgamio commented 4 years ago

For what it's worth, using threads instead of processes as outlined in #61 lets me run what I needed in Lambda

ArtemiyFirsov commented 4 years ago

Hey!

I think there should be the way to disable cache, as different platforms have different demands.

I would like to see the option on notion client to disable caching at all.