Last active
March 25, 2019 00:58
-
-
Save spestana/3038f9b9e9e34fc39ed13248ca894ef5 to your computer and use it in GitHub Desktop.
Framework for creating HydroShare resources.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from pysumma.hydroshare import hydroshare | |
# Establish connection with hydroshare | |
hs_up = hydroshare.hydroshare() | |
# Add metadata | |
title = 'Title of Resource' | |
abstract = 'Short description of the resource' | |
keywords = ('key', 'words', 'list') | |
resource_type = 'genericresource' | |
# Define the author for the resource | |
metadata = '[{"creator":{"name":"My Name"}}]' | |
# Define directories to pull files from | |
work_dir = '/home/user/work_directory' | |
data_dir = '/home/user/data_directory' | |
# Define the files that will be included in the resource | |
files = (work_dir + '/my_work_notebook.ipynb', | |
data_dir + '/my_data_file.nc') | |
# Send this to HydroShare as a new resource | |
resource_id = hs_up.createHydroShareResource(title=title, content_files=files, keywords=keywords, abstract=abstract, | |
resource_type=resource_type, public=False) | |
# Add a new file to this resource | |
hs_up.addContentToExistingResource(resource_id, | |
[new_file]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment