Skip to content

Commit

Permalink
fix: add ckanext.dc_serve.tmp_dir for temporary condense location
Browse files Browse the repository at this point in the history
  • Loading branch information
paulmueller committed Apr 16, 2024
1 parent 74a84d8 commit d718ec2
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
0.15.1
- fix: add ckanext.dc_serve.tmp_dir for temporary condense location
0.15.0
- BREAKING: drop support for DCOR API version "1"
- ref: migrate to dcor_shared 0.8.0
Expand Down
4 changes: 3 additions & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ This plugin implements:
- A background job that generates a condensed dataset after a resource
has been created.
- A background job that uploads the condensed dataset to the S3 object
store.
store. The temporary location of the condensed dataset that is created
can be set by setting the `ckanext.dc_serve.tmp_dir` configuration
option.
- A route that makes the condensed dataset available via
"/dataset/{id}/resource/{resource_id}/condensed.rtdc"
(S3 object store data is made available via a redirect)
Expand Down
9 changes: 7 additions & 2 deletions ckanext/dc_serve/jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,13 @@ def generate_condensed_resource_job(resource, override=False):
and (override
or not s3cc.artifact_exists(resource_id=rid,
artifact="condensed"))):
# Create the condensed file in a temporary location
with tempfile.TemporaryDirectory() as ttd_name:
# Create the condensed file in a cache location
cache_loc = get_ckan_config_option("ckanext.dc_serve.tmp_dir")
if not cache_loc:
cache_loc = None # probably defaults to /tmp in TemporaryDirectory

with tempfile.TemporaryDirectory(ignore_cleanup_errors=True,
dir=cache_loc) as ttd_name:
path_cond = pathlib.Path(ttd_name) / "condensed.rtdc"
with CKANResourceFileLock(
resource_id=rid,
Expand Down

0 comments on commit d718ec2

Please sign in to comment.