Skip to content

Commit 4cb4058

Browse files
committed
A few fixes :
upload file for v2 did not properly return the id of the uploaded file. added a text file (looks like the original was not checked in) gave it a more descriptive name.
1 parent da060b0 commit 4cb4058

File tree

3 files changed

+6
-2
lines changed

3 files changed

+6
-2
lines changed

pyclowder/files.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,8 @@ def upload_to_dataset(connector, host, key, datasetid, filepath, check_duplicate
287287
"""
288288
client = ClowderClient(host=host, key=key)
289289
if clowder_version == 2:
290-
v2files.upload_to_dataset(connector, client, datasetid, filepath, check_duplicate)
290+
uploadedfileid = v2files.upload_to_dataset(connector, client, datasetid, filepath, check_duplicate)
291+
return uploadedfileid
291292
else:
292293
logger = logging.getLogger(__name__)
293294

sample-extractors/test-dataset-extractor/test-dataset-extractor.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
import logging
66
import subprocess
7+
import os
78

89
from pyclowder.extractors import Extractor
910
import pyclowder.files
@@ -32,7 +33,7 @@ def process_message(self, connector, host, secret_key, resource, parameters):
3233
dataset_id = resource['id']
3334

3435
# Local file path to file which you want to upload to dataset
35-
file_path = 'a7.txt'
36+
file_path = os.path.join(os.getcwd(), 'test_dataset_extractor_file.txt')
3637

3738
# Upload a new file to dataset
3839
file_id = pyclowder.files.upload_to_dataset(connector, host, secret_key, dataset_id, file_path, True)
@@ -44,6 +45,7 @@ def process_message(self, connector, host, secret_key, resource, parameters):
4445
# Get file list under dataset
4546
file_list = pyclowder.datasets.get_file_list(connector, host, secret_key, dataset_id)
4647
logger.info("File list : %s", file_list)
48+
is_in = file_id in [file['id'] for file in file_list]
4749
if file_id in [file['id'] for file in file_list]:
4850
logger.info("File uploading and retrieving file list succeeded")
4951
else:
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
This is a test file for the test dataset extractor.

0 commit comments

Comments
 (0)