|
32 | 32 | "\n", |
33 | 33 | "The cache logic also support writing to cloud files seamlessly in addition to reading. We do this by tracking when a `CloudPath` is opened and on the close of that file, we will upload the new version to the cloud if it has changed.\n", |
34 | 34 | "\n", |
35 | | - "**Warning** we don't upload files that weren't opened for write by `cloudpathlib`. For example, if you edit a file in the cache manually in a text edior, `cloudpathlib` won't know to update that file on the cloud. If you want to write to a file in the cloud, you should use the `open` or `write` methods, for example:\n", |
| 35 | + "**Warning** we don't upload files that weren't opened for write by `cloudpathlib`. For example, if you edit a file in the cache manually in a text editor, `cloudpathlib` won't know to update that file on the cloud. If you want to write to a file in the cloud, you should use the `open` or `write` methods, for example:\n", |
36 | 36 | "\n", |
37 | 37 | "```python\n", |
38 | 38 | "with my_cloud_path.open(\"w\") as f:\n", |
|
269 | 269 | "\n", |
270 | 270 | "However, sometimes I don't want to have to re-download files I know won't change. For example, in the LADI dataset, I may want to use the images in a Jupyter notebook and every time I restart the notebook I want to always have the downloaded files. I don't want to ever re-download since I know the LADI images won't be changing on S3. I want these to be there, even if I restart my whole machine.\n", |
271 | 271 | "\n", |
272 | | - "We can do this just by using a `Client` that does all the downloading/uploading to a specfic folder on our local machine. We set the cache folder by passing `local_cache_dir` to the `Client` when instantiating. You can also set a default for all clients by setting the `CLOUDPATHLIB_LOCAL_CACHE_DIR` to a path. (This is only recommended with (1) an absolute path, so you know where the cache is no matter where your code is running, and (2) if you only use the default client for one cloud provider and don't instantiate multiple. In this case, the clients will use the same cache dir and could overwrite each other's content. Setting `CLOUDPATHLIB_LOCAL_CACHE_DIR` to an empty string will be treated as it not being set.)" |
| 272 | + "We can do this just by using a `Client` that does all the downloading/uploading to a specific folder on our local machine. We set the cache folder by passing `local_cache_dir` to the `Client` when instantiating. You can also set a default for all clients by setting the `CLOUDPATHLIB_LOCAL_CACHE_DIR` to a path. (This is only recommended with (1) an absolute path, so you know where the cache is no matter where your code is running, and (2) if you only use the default client for one cloud provider and don't instantiate multiple. In this case, the clients will use the same cache dir and could overwrite each other's content. Setting `CLOUDPATHLIB_LOCAL_CACHE_DIR` to an empty string will be treated as it not being set.)" |
273 | 273 | ] |
274 | 274 | }, |
275 | 275 | { |
|
433 | 433 | " - `*Client.clear_cache()` - All files downloaded by this specific client instance will be removed from the cache. If you didn't create a client instance yourself, you can get the one that is used by a cloudpath with `CloudPath.client` or get the default one for a particular provider with `get_default_client`, for example by calling `S3Client.get_default_client().clear_cache()`.\n", |
434 | 434 | " - By deleting the cached file itself or the containing directory using any normal method. To see where on a disk the cache is, you can use `CloudPath.fspath` for an individual file or use `*Client._local_cache_dir` for the client's cache. You can then use any method you like to delete these local files.\n", |
435 | 435 | "\n", |
436 | | - "However, for most cases, you shouldn't need to manage the file cache manually. By setting the automatic cache clearing beahvior to the most appropriate one for your use case below, you can have the cache automatically cleared.\n" |
| 436 | + "However, for most cases, you shouldn't need to manage the file cache manually. By setting the automatic cache clearing behavior to the most appropriate one for your use case below, you can have the cache automatically cleared.\n" |
437 | 437 | ] |
438 | 438 | }, |
439 | 439 | { |
|
647 | 647 | "source": [ |
648 | 648 | "### File cache mode: `\"persistent\"`\n", |
649 | 649 | "\n", |
650 | | - "If `local_cache_dir` is specificed, but `file_cache_mode` is not, then the mode is set to `\"persistent\"` automatically. Conversely, if you set the mode to `\"persistent\"` explicitly, you must also pass `local_cache_dir` or the `Client` will raise `InvalidConfigurationException`.\n", |
| 650 | + "If `local_cache_dir` is specified, but `file_cache_mode` is not, then the mode is set to `\"persistent\"` automatically. Conversely, if you set the mode to `\"persistent\"` explicitly, you must also pass `local_cache_dir` or the `Client` will raise `InvalidConfigurationException`.\n", |
651 | 651 | "\n", |
652 | 652 | "Local cache file exists after file is closed for reading.\n", |
653 | 653 | "\n", |
|
0 commit comments