You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The calling statement for creating a resource in the current welcome notebook is
# create the new resource
resource_id = hs.createHydroShareResource(abstract,
title,
keywords=keywords,
resource_type=rtype,
content_files=files,
public=False)
However print(resource_id) following this returns "None"
I am not sure if the design intention was for this function to return resource_id, but either the function hs.createHydroShareResource should be fixed to return this id, or we should not use a statement like the above to illustrate functionality in the welcome notebook.
In discussing this with @sblack-usu there is a question as to why we are using a wrapper (hydrology.py) for the REST client which is already a wrapper for the REST API. Should we not be directly using REST client functions in our example notebooks.
The text was updated successfully, but these errors were encountered:
I'll take a look at the return value for createHydroShareResource...this sounds like a bug.
@dtarb@sblack-usu
The reason for the wrapper is to make resource creation easier from within a notebook, but it's not required which is why it's included as a utility library (utilities.hydroshare). Users are encouraged to use whatever method they want to interact with HydroShare, but the following code is the minimum required to accomplish the same task as the above (without threading or error messaging) using the hs_restclient.
# query the hydroshare resource types and make sure that
# resource_type is valid
restypes = {r.lower(): r for r in hs.getResourceTypes()}
res_type = restypes[resource_type]
# get the 'derived resource' metadata
if derivedFromId is not None:
science_meta = hs.getScienceMetadata(resid)
system_meta = hs.getSystemMetadata(resid)
# you would need to write a function to handle metadata
meta = MY_FUNCTION_TO_PARSE_METADATA(system_meta, science_meta)
abstract = meta.abstract \
+ '\n\n[Modified in JupyterHub on %s]\n%s' \
% (dt.now(), abstract)
keywords = set(keywords + meta.keywords)
f = None if len(content_files) == 0 else content_files[0]
# create the hs resource (1 content file allowed)
resid = hs.createResource(resource_type=res_type,
title=title,
abstract=abstract,
resource_file=f,
keywords=keywords)
# add the remaining content files to the hs resource
if len(content_files) > 1:
for f in content_files:
self.hs.addResourceFile(resid, f)
The calling statement for creating a resource in the current welcome notebook is
However print(resource_id) following this returns "None"
I am not sure if the design intention was for this function to return resource_id, but either the function hs.createHydroShareResource should be fixed to return this id, or we should not use a statement like the above to illustrate functionality in the welcome notebook.
In discussing this with @sblack-usu there is a question as to why we are using a wrapper (hydrology.py) for the REST client which is already a wrapper for the REST API. Should we not be directly using REST client functions in our example notebooks.
The text was updated successfully, but these errors were encountered: