Skip to content

Commit 5dadb29

Browse files
committed
don't track extractor downloads (fixes #55)
1 parent 4a067ff commit 5dadb29

File tree

3 files changed

+14
-4
lines changed

3 files changed

+14
-4
lines changed

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,14 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](http://keepachangelog.com/)
55
and this project adheres to [Semantic Versioning](http://semver.org/).
66

7+
## 2.7.0 - 2023-02-14
8+
9+
When extractors download a file from clowder it will ask clowder to not track that download.
10+
This will result in only those donwloads to be counted by users, not extractors.
11+
12+
### Changed
13+
- Ask not to track a download from an extractor.
14+
715
## 2.6.0 - 2022-06-14
816

917
This will change how clowder sees the extractors. If you have an extractor, and you specify

pyclowder/connectors.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@ def _prepare_dataset(self, host, secret_key, resource):
332332
for ds_file in missing_files:
333333
# Download file to temp directory
334334
inputfile = pyclowder.files.download(self, host, secret_key, ds_file['id'], ds_file['id'],
335-
ds_file['file_ext'])
335+
ds_file['file_ext'], tracking=False)
336336
# Also get file metadata in format expected by extractor
337337
(file_md_dir, file_md_tmp) = self._download_file_metadata(host, secret_key, ds_file['id'],
338338
ds_file['filepath'])
@@ -425,7 +425,8 @@ def _process_message(self, body):
425425
if not file_path:
426426
file_path = pyclowder.files.download(self, host, secret_key, resource["id"],
427427
resource["intermediate_id"],
428-
resource["file_ext"])
428+
resource["file_ext"],
429+
tracking=False)
429430
else:
430431
found_local = True
431432
resource['local_paths'] = [file_path]

pyclowder/files.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525

2626

2727
# pylint: disable=too-many-arguments
28-
def download(connector, host, key, fileid, intermediatefileid=None, ext=""):
28+
def download(connector, host, key, fileid, intermediatefileid=None, ext="", tracking=True):
2929
"""Download file to be processed from Clowder.
3030
3131
Keyword arguments:
@@ -35,6 +35,7 @@ def download(connector, host, key, fileid, intermediatefileid=None, ext=""):
3535
fileid -- the file that is currently being processed
3636
intermediatefileid -- either same as fileid, or the intermediate file to be used
3737
ext -- the file extension, the downloaded file will end with this extension
38+
tracking -- should the download action be tracked
3839
"""
3940

4041
connector.message_process({"type": "file", "id": fileid}, "Downloading file.")
@@ -43,7 +44,7 @@ def download(connector, host, key, fileid, intermediatefileid=None, ext=""):
4344
if not intermediatefileid:
4445
intermediatefileid = fileid
4546

46-
url = '%sapi/files/%s?key=%s' % (host, intermediatefileid, key)
47+
url = '%sapi/files/%s?key=%s&tracking=%s' % (host, intermediatefileid, key, str(tracking).lower())
4748
result = connector.get(url, stream=True, verify=connector.ssl_verify if connector else True)
4849

4950
(inputfile, inputfilename) = tempfile.mkstemp(suffix=ext)

0 commit comments

Comments
 (0)