diff --git a/docs/examples/Aggregation_Data_Object_Operations.ipynb b/docs/examples/Aggregation_Data_Object_Operations.ipynb index 4b3dc05..2042761 100644 --- a/docs/examples/Aggregation_Data_Object_Operations.ipynb +++ b/docs/examples/Aggregation_Data_Object_Operations.ipynb @@ -38,14 +38,14 @@ }, { "cell_type": "code", - "execution_count": null, - "outputs": [], "source": [ "!pip install hsclient[all]" ], "metadata": { "collapsed": false - } + }, + "outputs": [], + "execution_count": null }, { "cell_type": "markdown", @@ -60,8 +60,6 @@ }, { "cell_type": "code", - "execution_count": null, - "outputs": [], "source": [ "import os\n", "from hsclient import HydroShare\n", @@ -71,7 +69,9 @@ ], "metadata": { "collapsed": false - } + }, + "outputs": [], + "execution_count": null }, { "cell_type": "markdown", @@ -93,8 +93,6 @@ }, { "cell_type": "code", - "execution_count": null, - "outputs": [], "source": [ "# first we need to get the resource object from HydroShare using id of the resource\n", "resource_id = 'a0e0c2e2e5e84e1e9b6b2b2b2b2b2b2b'\n", @@ -104,7 +102,9 @@ ], "metadata": { "collapsed": false - } + }, + "outputs": [], + "execution_count": null }, { "cell_type": "markdown", @@ -118,8 +118,6 @@ }, { "cell_type": "code", - "execution_count": null, - "outputs": [], "source": [ "# retrieve the time series aggregation\n", "file_path = \"sample.sqlite\"\n", @@ -127,37 +125,34 @@ ], "metadata": { "collapsed": false - } + }, + "outputs": [], + "execution_count": null }, { + "metadata": {}, "cell_type": "code", - "execution_count": null, - "outputs": [], "source": [ "# show the aggregation type\n", "print(f\"Aggregation Type:{ts_aggr.metadata.type}\")" ], - "metadata": { - "collapsed": false - } + "outputs": [], + "execution_count": null }, { + "metadata": {}, "cell_type": "code", - "execution_count": null, - "outputs": [], "source": [ "# display the time series results metadata to see the all available series\n", "# later we will use one of the series ids to retrieve the time series data\n", "print(ts_aggr.metadata.time_series_results)" ], - "metadata": { - "collapsed": false - } + "outputs": [], + "execution_count": null }, { + "metadata": {}, "cell_type": "code", - "execution_count": null, - "outputs": [], "source": [ "# download the time series aggregation - these directory paths must exist for hsclient to download and unzip the aggregation zip file\n", "# Note: These directory paths need to be changed based on where you want to download the aggregation\n", @@ -167,30 +162,27 @@ "aggr_path = resource.aggregation_download(aggregation=ts_aggr, save_path=download_to, unzip_to=unzip_to)\n", "print(f\"Downloaded aggregation to:{aggr_path}\")" ], - "metadata": { - "collapsed": false - } + "outputs": [], + "execution_count": null }, { + "metadata": {}, "cell_type": "code", - "execution_count": null, - "outputs": [], "source": [ "# load a given time series of the aggregation as pandas.DataFrame from the downloaded location (aggr_path)\n", + "\n", "# Note: Here we are assuming the series id used below is one of the ids we found when we printed the\n", "# time series results in the earlier coding step\n", + "\n", "series_id = '51e31687-1ebc-11e6-aa6c-f45c8999816f'\n", "pd_dataframe = ts_aggr.as_data_object(series_id=series_id, agg_path=aggr_path)\n", "print(f\"Type of data processing object:{type(pd_dataframe)}\")" ], - "metadata": { - "collapsed": false - } + "outputs": [], + "execution_count": null }, { "cell_type": "code", - "execution_count": null, - "outputs": [], "source": [ "# now we can use the pandas.DataFrame to do some data analysis\n", "\n", @@ -199,48 +191,48 @@ ], "metadata": { "collapsed": false - } + }, + "outputs": [], + "execution_count": null }, { "cell_type": "code", - "execution_count": null, - "outputs": [], "source": [ "# show time series data summary\n", "print(pd_dataframe.info)" ], "metadata": { "collapsed": false - } + }, + "outputs": [], + "execution_count": null }, { "cell_type": "code", - "execution_count": null, - "outputs": [], "source": [ "# show number of data points in time series\n", "print(pd_dataframe.size)" ], "metadata": { "collapsed": false - } + }, + "outputs": [], + "execution_count": null }, { "cell_type": "code", - "execution_count": null, - "outputs": [], "source": [ "# show first 5 records in time series\n", "print(pd_dataframe.head(5))" ], "metadata": { "collapsed": false - } + }, + "outputs": [], + "execution_count": null }, { "cell_type": "code", - "execution_count": null, - "outputs": [], "source": [ "# editing time series aggregation data using the pandas.DataFrame\n", "print(f\"Data frame size before edit:{pd_dataframe.size}\")\n", @@ -250,12 +242,12 @@ ], "metadata": { "collapsed": false - } + }, + "outputs": [], + "execution_count": null }, { "cell_type": "code", - "execution_count": null, - "outputs": [], "source": [ "# delete 10 rows from the dataframe. This will result in deleting 10 records from the 'TimeSeriesResultValues' table when we save the dataframe.\n", "pd_dataframe.drop(pd_dataframe.index[0:10], axis=0, inplace=True)\n", @@ -267,43 +259,44 @@ ], "metadata": { "collapsed": false - } + }, + "outputs": [], + "execution_count": null }, { "cell_type": "code", - "execution_count": null, - "outputs": [], "source": [ "# save the updated dataframe object to the time series aggregation in HydroShare\n", - "# Note this will update the data for the existing time series aggregation in HydroShare\n", + "# Note this will update the data for the existing time series aggregation in HydroShare - this operation may take a while \n", "ts_aggr = ts_aggr.save_data_object(resource=resource, agg_path=aggr_path, as_new_aggr=False)\n", "print(f\"Updated time series aggregation ...\")" ], "metadata": { "collapsed": false - } + }, + "outputs": [], + "execution_count": null }, { "cell_type": "code", - "execution_count": null, - "outputs": [], "source": [ "# we can also create a new time series aggregation in HydroShare using the updated dataframe object\n", "# we will first create a new folder in which the new aggregation will be created\n", "aggr_folder = \"ts_folder\"\n", "resource.folder_create(folder=aggr_folder)\n", + "# this operation may take a while \n", "ts_aggr = ts_aggr.save_data_object(resource=resource, agg_path=aggr_path, as_new_aggr=True,\n", " destination_path=aggr_folder)\n", "print(f\"Created a new time series aggregation ...\")" ], "metadata": { "collapsed": false - } + }, + "outputs": [], + "execution_count": null }, { "cell_type": "code", - "execution_count": null, - "outputs": [], "source": [ "# retrieve the updated time series aggregation to verify the data was updated\n", "# reload the new timeseries as pandas.DataFrame\n", @@ -319,7 +312,9 @@ ], "metadata": { "collapsed": false - } + }, + "outputs": [], + "execution_count": null }, { "cell_type": "markdown", @@ -333,8 +328,6 @@ }, { "cell_type": "code", - "execution_count": null, - "outputs": [], "source": [ "# retrieve the geographic feature aggregation\n", "file_path = \"sample.shp\"\n", @@ -342,24 +335,24 @@ ], "metadata": { "collapsed": false - } + }, + "outputs": [], + "execution_count": null }, { "cell_type": "code", - "execution_count": null, - "outputs": [], "source": [ "# show the aggregation type\n", "print(f\"Aggregation Type:{gf_aggr.metadata.type}\")" ], "metadata": { "collapsed": false - } + }, + "outputs": [], + "execution_count": null }, { "cell_type": "code", - "execution_count": null, - "outputs": [], "source": [ "# download the geographic feature aggregation - these directory paths must exist for hsclient to download and unzip the aggregation zip file\n", "# Note: These directory paths need to be changed based on where you want to download the aggregation\n", @@ -370,12 +363,12 @@ ], "metadata": { "collapsed": false - } + }, + "outputs": [], + "execution_count": null }, { "cell_type": "code", - "execution_count": null, - "outputs": [], "source": [ "# load the downloaded geo-feature aggregation as a fiona Collection object\n", "fiona_coll = gf_aggr.as_data_object(agg_path=aggr_path)\n", @@ -383,12 +376,12 @@ ], "metadata": { "collapsed": false - } + }, + "outputs": [], + "execution_count": null }, { "cell_type": "code", - "execution_count": null, - "outputs": [], "source": [ "# now we can use the fiona.Collection object to do some data analysis\n", "\n", @@ -397,60 +390,60 @@ ], "metadata": { "collapsed": false - } + }, + "outputs": [], + "execution_count": null }, { "cell_type": "code", - "execution_count": null, - "outputs": [], "source": [ "# show feature collection coordinate reference system\n", "print(fiona_coll.crs)" ], "metadata": { "collapsed": false - } + }, + "outputs": [], + "execution_count": null }, { "cell_type": "code", - "execution_count": null, - "outputs": [], "source": [ "# show feature collection spatial coverage\n", "print(fiona_coll.bounds)" ], "metadata": { "collapsed": false - } + }, + "outputs": [], + "execution_count": null }, { "cell_type": "code", - "execution_count": null, - "outputs": [], "source": [ "# show number of features/bands\n", "print(len(list(fiona_coll)))" ], "metadata": { "collapsed": false - } + }, + "outputs": [], + "execution_count": null }, { "cell_type": "code", - "execution_count": null, - "outputs": [], "source": [ "# show feature field information\n", "print(fiona_coll.schema)" ], "metadata": { "collapsed": false - } + }, + "outputs": [], + "execution_count": null }, { "cell_type": "code", - "execution_count": null, - "outputs": [], "source": [ "# show data for a single feature in feature collection\n", "from fiona.model import to_dict\n", @@ -460,12 +453,12 @@ ], "metadata": { "collapsed": false - } + }, + "outputs": [], + "execution_count": null }, { "cell_type": "code", - "execution_count": null, - "outputs": [], "source": [ "# editing geographic feature aggregation data using the fiona.Collection object\n", "import fiona\n", @@ -493,43 +486,46 @@ ], "metadata": { "collapsed": false - } + }, + "outputs": [], + "execution_count": null }, { "cell_type": "code", - "execution_count": null, - "outputs": [], "source": [ - "# we can now update the geographic feature aggregation in HydroShare using the updated shp file\n", + "# we can now update the geographic feature aggregation in HydroShare using the updated shp file - this operation may take a while \n", "gf_aggr = gf_aggr.save_data_object(resource=resource, agg_path=output_shp_file_dir_path, as_new_aggr=False)\n", "print(\"Aggregation updated ...\")" ], "metadata": { "collapsed": false - } + }, + "outputs": [], + "execution_count": null }, { "cell_type": "code", - "execution_count": null, - "outputs": [], "source": [ "# we can also create a new geographic feature aggregation in HydroShare using the updated shp file\n", "\n", "# we will first create a new folder in which the new aggregation will be created in HydroShare\n", "aggr_folder = \"gf_folder\"\n", "resource.folder_create(folder=aggr_folder)\n", + "# first retrieve the data object from the updated shp file - this step is not needed if your have not saved the object previously\n", + "fiona_coll = gf_aggr.as_data_object(agg_path=output_shp_file_dir_path)\n", + "# this operation may take a while\n", "gf_aggr = gf_aggr.save_data_object(resource=resource, agg_path=output_shp_file_dir_path, as_new_aggr=True,\n", " destination_path=aggr_folder)\n", "print(\"New aggregation created ...\")" ], "metadata": { "collapsed": false - } + }, + "outputs": [], + "execution_count": null }, { "cell_type": "code", - "execution_count": null, - "outputs": [], "source": [ "# retrieve the updated geographic feature aggregation to verify the data was updated\n", "# need to first download this updated/new aggregation\n", @@ -540,7 +536,9 @@ ], "metadata": { "collapsed": false - } + }, + "outputs": [], + "execution_count": null }, { "cell_type": "markdown", @@ -554,8 +552,6 @@ }, { "cell_type": "code", - "execution_count": null, - "outputs": [], "source": [ "# retrieve the multidimensional aggregation\n", "file_path = \"sample.nc\"\n", @@ -564,28 +560,28 @@ ], "metadata": { "collapsed": false - } + }, + "outputs": [], + "execution_count": null }, { "cell_type": "code", - "execution_count": null, - "outputs": [], "source": [ "# download the multidimensional aggregation - these directory paths must exist for hsclient to download and unzip the aggregation zip file\n", "# Note: These directory paths need to be changed based on where you want to download the aggregation\n", - "download_to = r\"D:\\Temp\\MultiDim_Testing\"\n", + "download_to = r\"D:\\Temp\\NetCDF_Testing\"\n", "unzip_to = rf\"{download_to}\\aggr_unzipped\"\n", "aggr_path = resource.aggregation_download(aggregation=md_aggr, save_path=download_to, unzip_to=unzip_to)\n", "print(f\"Downloaded aggregation to:{aggr_path}\")" ], "metadata": { "collapsed": false - } + }, + "outputs": [], + "execution_count": null }, { "cell_type": "code", - "execution_count": null, - "outputs": [], "source": [ "# load the downloaded multidimensional aggregation as a xarray.Dataset object\n", "xarray_ds = md_aggr.as_data_object(agg_path=aggr_path)\n", @@ -593,12 +589,12 @@ ], "metadata": { "collapsed": false - } + }, + "outputs": [], + "execution_count": null }, { "cell_type": "code", - "execution_count": null, - "outputs": [], "source": [ "# now we can use the xarray.Dataset object to do some data analysis\n", "\n", @@ -607,36 +603,36 @@ ], "metadata": { "collapsed": false - } + }, + "outputs": [], + "execution_count": null }, { "cell_type": "code", - "execution_count": null, - "outputs": [], "source": [ "# show netcdf dimensions\n", "print(xarray_ds.dims)" ], "metadata": { "collapsed": false - } + }, + "outputs": [], + "execution_count": null }, { "cell_type": "code", - "execution_count": null, - "outputs": [], "source": [ "# show coordinate variables of the netcdf dataset\n", "print(xarray_ds.coords)" ], "metadata": { "collapsed": false - } + }, + "outputs": [], + "execution_count": null }, { "cell_type": "code", - "execution_count": null, - "outputs": [], "source": [ "# editing multidimensional aggregation data using the xarray.Dataset object\n", "\n", @@ -646,43 +642,46 @@ ], "metadata": { "collapsed": false - } + }, + "outputs": [], + "execution_count": null }, { "cell_type": "code", - "execution_count": null, - "outputs": [], "source": [ - "# we can update the multidimensional aggregation in HydroShare using the updated xarray.Dataset object\n", + "# we can update the multidimensional aggregation in HydroShare using the updated xarray.Dataset object - this operation may take a while\n", "md_aggr = md_aggr.save_data_object(resource=resource, agg_path=aggr_path, as_new_aggr=False)\n", "print(\"Aggregation updated ...\")" ], "metadata": { "collapsed": false - } + }, + "outputs": [], + "execution_count": null }, { "cell_type": "code", - "execution_count": null, - "outputs": [], "source": [ "# we can also create a new multidimensional aggregation in HydroShare using the updated xarray.Dataset object\n", "\n", "# we will first create a new folder in which the new aggregation will be created\n", "aggr_folder = \"md_folder\"\n", "resource.folder_create(folder=aggr_folder)\n", + "# first retrieve the data object from the updated netcdf file - this step is not needed if your have not saved the object previously\n", + "xarray_ds = md_aggr.as_data_object(agg_path=aggr_path)\n", + "# this operation may take a while\n", "md_aggr = md_aggr.save_data_object(resource=resource, agg_path=aggr_path, as_new_aggr=True,\n", " destination_path=aggr_folder)\n", "print(\"New aggregation created ...\")" ], "metadata": { "collapsed": false - } + }, + "outputs": [], + "execution_count": null }, { "cell_type": "code", - "execution_count": null, - "outputs": [], "source": [ "# retrieve the updated multidimensional aggregation to verify the data was updated\n", "\n", @@ -694,7 +693,9 @@ ], "metadata": { "collapsed": false - } + }, + "outputs": [], + "execution_count": null }, { "cell_type": "markdown", @@ -708,8 +709,6 @@ }, { "cell_type": "code", - "execution_count": null, - "outputs": [], "source": [ "# retrieve the georaster aggregation\n", "file_path = \"sample.tif\"\n", @@ -718,12 +717,12 @@ ], "metadata": { "collapsed": false - } + }, + "outputs": [], + "execution_count": null }, { "cell_type": "code", - "execution_count": null, - "outputs": [], "source": [ "# download the georaster aggregation - these directory paths must exist for hsclient to download and unzip the aggregation zip file\n", "# Note: These directory paths need to be changed based on where you want to download the aggregation\n", @@ -734,12 +733,12 @@ ], "metadata": { "collapsed": false - } + }, + "outputs": [], + "execution_count": null }, { "cell_type": "code", - "execution_count": null, - "outputs": [], "source": [ "# load the downloaded georaster aggregation as a rasterio.DatasetReader object\n", "rasterio_ds = gr_aggr.as_data_object(agg_path=aggr_path)\n", @@ -747,12 +746,12 @@ ], "metadata": { "collapsed": false - } + }, + "outputs": [], + "execution_count": null }, { "cell_type": "code", - "execution_count": null, - "outputs": [], "source": [ "# now we can use the rasterio.DatasetReader object to do some data analysis\n", "\n", @@ -761,48 +760,48 @@ ], "metadata": { "collapsed": false - } + }, + "outputs": [], + "execution_count": null }, { "cell_type": "code", - "execution_count": null, - "outputs": [], "source": [ "# show raster band dimensions\n", "print(rasterio_ds.width, rasterio_ds.height)" ], "metadata": { "collapsed": false - } + }, + "outputs": [], + "execution_count": null }, { "cell_type": "code", - "execution_count": null, - "outputs": [], "source": [ "# show raster coordinate reference system\n", "print(rasterio_ds.crs)" ], "metadata": { "collapsed": false - } + }, + "outputs": [], + "execution_count": null }, { "cell_type": "code", - "execution_count": null, - "outputs": [], "source": [ "# show raster bounds\n", "print(rasterio_ds.bounds)" ], "metadata": { "collapsed": false - } + }, + "outputs": [], + "execution_count": null }, { "cell_type": "code", - "execution_count": null, - "outputs": [], "source": [ "# show raster data\n", "data = rasterio_ds.read()\n", @@ -810,12 +809,12 @@ ], "metadata": { "collapsed": false - } + }, + "outputs": [], + "execution_count": null }, { "cell_type": "code", - "execution_count": null, - "outputs": [], "source": [ "# editing georaster aggregation data using the rasterio.DatasetReader object\n", "from rasterio.windows import Window\n", @@ -833,14 +832,16 @@ ], "metadata": { "collapsed": false - } + }, + "outputs": [], + "execution_count": null }, { "cell_type": "code", - "execution_count": null, - "outputs": [], "source": [ - "# write the subset data to a new tif file\n", + "# write the subset data to a new tif file - note the target directory must be empty\n", + "# Note: The original raster aggregation may have more than one tif files. The following update will always result in an updated or new aggregation\n", + "# with a single tif file.\n", "\n", "output_raster_dir_path = r\"D:\\Temp\\GeoRaster_Testing\\updated_aggr\"\n", "output_raster_filename = \"out_sample.tif\"\n", @@ -858,47 +859,70 @@ ], "metadata": { "collapsed": false - } + }, + "outputs": [], + "execution_count": null }, { "cell_type": "code", - "execution_count": null, - "outputs": [], "source": [ - "# we can update the georaster aggregation in HydroShare using the updated rasterio.DatasetReader object\n", + "# we can update the georaster aggregation in HydroShare using the updated rasterio.DatasetReader object - this operation may take a while\n", "gr_aggr = gr_aggr.save_data_object(resource=resource, agg_path=output_raster_dir_path, as_new_aggr=False)\n", "print(\"Aggregation updated ...\")" ], "metadata": { "collapsed": false - } + }, + "outputs": [], + "execution_count": null }, { + "metadata": {}, "cell_type": "code", - "execution_count": null, + "source": [ + "# we can also create a new georaster aggregation in HydroShare using the updated rasterio.DatasetReader object\n", + "\n", + "# If you have already updated the aggregation as described in the previous cell, then you have to first download the updated aggregation and load the\n", + "# rasterio.DatasetReader object from the downloaded location before you can save the updated raster to a new aggregation in HydroShare as shown below. Otherwise, you can execute the code in the next cell.\n", + "\n", + "download_to = r\"D:\\Temp\\GeoRaster_Testing\"\n", + "# note the unzip_to directory must exist and be empty\n", + "unzip_to = rf\"{download_to}\\updated_aggr_unzipped\"\n", + "aggr_path = resource.aggregation_download(aggregation=gr_aggr, save_path=download_to, unzip_to=unzip_to)\n", + "print(f\"Downloaded aggregation to:{aggr_path}\")\n", + "\n", + "# reload the updated raster as rasterio.DatasetReader\n", + "rasterio_ds = gr_aggr.as_data_object(agg_path=aggr_path)" + ], "outputs": [], + "execution_count": null + }, + { + "metadata": {}, + "cell_type": "code", "source": [ "# we can also create a new georaster aggregation in HydroShare using the updated rasterio.DatasetReader object\n", "\n", "# we will first create a new folder in which the new aggregation will be created\n", "aggr_folder = \"gr_folder\"\n", "resource.folder_create(folder=aggr_folder)\n", + "# this operation may take a while\n", "gr_aggr = gr_aggr.save_data_object(resource=resource, agg_path=output_raster_dir_path, as_new_aggr=True,\n", " destination_path=aggr_folder)\n", "print(\"New aggregation created ...\")" ], - "metadata": { - "collapsed": false - } + "outputs": [], + "execution_count": null }, { "cell_type": "code", - "execution_count": null, - "outputs": [], "source": [ "# retrieve the updated georaster aggregation to verify the data was updated\n", "\n", "# need to first download this updated/new aggregation\n", + "download_to = r\"D:\\Temp\\GeoRaster_Testing\"\n", + "# note the unzip_to directory must exist and be empty\n", + "unzip_to = rf\"{download_to}\\aggr_unzipped\"\n", "aggr_path = resource.aggregation_download(aggregation=gr_aggr, save_path=download_to, unzip_to=unzip_to)\n", "rasterio_ds = gr_aggr.as_data_object(agg_path=aggr_path)\n", "# check the raster dimensions of the updated aggregation\n", @@ -908,7 +932,9 @@ ], "metadata": { "collapsed": false - } + }, + "outputs": [], + "execution_count": null } ], "metadata": { diff --git a/docs/examples/Aggregation_Operations.ipynb b/docs/examples/Aggregation_Operations.ipynb index d27f5a1..94f025b 100644 --- a/docs/examples/Aggregation_Operations.ipynb +++ b/docs/examples/Aggregation_Operations.ipynb @@ -28,14 +28,14 @@ }, { "cell_type": "code", - "execution_count": null, "metadata": { "id": "hzriLgMl0oJ2" }, - "outputs": [], "source": [ "!pip install hsclient" - ] + ], + "outputs": [], + "execution_count": null }, { "cell_type": "markdown", @@ -50,17 +50,17 @@ }, { "cell_type": "code", - "execution_count": null, "metadata": { "id": "3njsiY73m7_V" }, - "outputs": [], "source": [ "from hsclient import HydroShare\n", "\n", "hs = HydroShare()\n", "hs.sign_in()" - ] + ], + "outputs": [], + "execution_count": null }, { "cell_type": "markdown", @@ -77,11 +77,9 @@ }, { "cell_type": "code", - "execution_count": null, "metadata": { "id": "W9azvJ_Co87w" }, - "outputs": [], "source": [ "# Create the new, empty resource\n", "new_resource = hs.create()\n", @@ -92,7 +90,9 @@ "\n", "# Construct a hyperlink for the new resource\n", "print(f'Your new resource is available at: {new_resource.metadata.url}')" - ] + ], + "outputs": [], + "execution_count": null }, { "cell_type": "markdown", @@ -127,11 +127,9 @@ }, { "cell_type": "code", - "execution_count": null, "metadata": { "id": "sCvGL4g-PGXS" }, - "outputs": [], "source": [ "# Import the aggregation types\n", "from hsmodels.schemas.enums import AggregationType\n", @@ -149,7 +147,9 @@ "# Print the title for the aggregation that was added to the resource\n", "print(f'The following aggregation was added to the resource: {agg.metadata.title}')\n", "print(f'Aggregation type: {agg.metadata.type}')" - ] + ], + "outputs": [], + "execution_count": null }, { "cell_type": "markdown", @@ -177,9 +177,7 @@ }, { "cell_type": "code", - "execution_count": null, "metadata": {}, - "outputs": [], "source": [ "# Set the title and subject keywords for the aggregation\n", "agg.metadata.title = 'A CSV Data File Single File Aggregation'\n", @@ -191,7 +189,9 @@ "\n", "# Save the aggregation to write the metadata to HydroShare\n", "agg.save()" - ] + ], + "outputs": [], + "execution_count": null }, { "cell_type": "markdown", @@ -206,9 +206,7 @@ }, { "cell_type": "code", - "execution_count": null, "metadata": {}, - "outputs": [], "source": [ "# Add an extended metadata element to the aggregation as a key-value pair\n", "agg.metadata.additional_metadata['New Element Key'] = 'Text value of new element.'\n", @@ -232,7 +230,9 @@ "\n", "# Save the aggregation to write the metadata to HydroShare\n", "agg.save()" - ] + ], + "outputs": [], + "execution_count": null }, { "cell_type": "markdown", @@ -247,9 +247,7 @@ }, { "cell_type": "code", - "execution_count": null, "metadata": {}, - "outputs": [], "source": [ "# Import the required metadata classes for coverage objects\n", "from hsmodels.schemas.fields import BoxCoverage, PointCoverage, PeriodCoverage\n", @@ -293,7 +291,9 @@ "\n", "# Save the aggregation to write the metadata to HydroShare\n", "agg.save()" - ] + ], + "outputs": [], + "execution_count": null }, { "cell_type": "markdown", @@ -317,9 +317,7 @@ }, { "cell_type": "code", - "execution_count": null, "metadata": {}, - "outputs": [], "source": [ "# Create a list of the files that make up the shapefile to be uploaded\n", "file_list = ['Example_Files/watersheds.cpg', 'Example_Files/watersheds.dbf',\n", @@ -331,7 +329,9 @@ "new_resource.file_upload(*file_list)\n", "\n", "print('Files uploaded!')" - ] + ], + "outputs": [], + "execution_count": null }, { "cell_type": "markdown", @@ -346,9 +346,7 @@ }, { "cell_type": "code", - "execution_count": null, "metadata": {}, - "outputs": [], "source": [ "# Get the aggregation that was just created\n", "\n", @@ -362,7 +360,9 @@ "# Print the title for the aggregation that was added to the resource\n", "print(f'The following aggregation was added to the resource: {agg.metadata.title}')\n", "print(f'Aggregation type: {agg.metadata.type}')" - ] + ], + "outputs": [], + "execution_count": null }, { "cell_type": "markdown", @@ -379,9 +379,7 @@ }, { "cell_type": "code", - "execution_count": null, "metadata": {}, - "outputs": [], "source": [ "# Upload the files making up the raster dataset to the resource\n", "file_list = ['Example_Files/logan1.tif', 'Example_Files/logan2.tif', 'Example_Files/logan.vrt']\n", @@ -394,7 +392,9 @@ "# Print the title for the aggregation that was added to the resource\n", "print(f'The following aggregation was added to the resource: {agg.metadata.title}')\n", "print(f'Aggregation type: {agg.metadata.type}')" - ] + ], + "outputs": [], + "execution_count": null }, { "cell_type": "markdown", @@ -409,9 +409,7 @@ }, { "cell_type": "code", - "execution_count": null, "metadata": {}, - "outputs": [], "source": [ "# Upload the NetCDF file to the resource\n", "new_resource.file_upload('Example_Files/SWE_time.nc')\n", @@ -422,7 +420,9 @@ "# Print the title for the aggregation that was added to the resource\n", "print(f'The following aggregation was added to the resource: {agg.metadata.title}')\n", "print(f'Aggregation type: {agg.metadata.type}')" - ] + ], + "outputs": [], + "execution_count": null }, { "cell_type": "markdown", @@ -437,9 +437,7 @@ }, { "cell_type": "code", - "execution_count": null, "metadata": {}, - "outputs": [], "source": [ "# Upload the SQLite file to the resource\n", "new_resource.file_upload('Example_Files/ODM2.sqlite')\n", @@ -450,7 +448,9 @@ "# Print the title for the aggregation that was added to the resource\n", "print(f'The following aggregation was added to the resource: {agg.metadata.title}')\n", "print(f'Aggregation type: {agg.metadata.type}')" - ] + ], + "outputs": [], + "execution_count": null }, { "cell_type": "markdown", @@ -465,9 +465,7 @@ }, { "cell_type": "code", - "execution_count": null, "metadata": {}, - "outputs": [], "source": [ "# Create a new folder for the file set aggregation\n", "new_resource.folder_create('Fileset_Aggregation')\n", @@ -477,7 +475,9 @@ " destination_path='Fileset_Aggregation')\n", "\n", "# TODO: How to set a fileset aggregation on a folder containing files?" - ] + ], + "outputs": [], + "execution_count": null }, { "cell_type": "markdown", @@ -492,9 +492,7 @@ }, { "cell_type": "code", - "execution_count": null, "metadata": {}, - "outputs": [], "source": [ "# Get the time series aggregation that was created above\n", "agg = new_resource.aggregation(type='TimeSeries')\n", @@ -510,7 +508,9 @@ "file_list = agg.files()\n", "print('List of files contained within the aggregation:')\n", "print(*file_list, sep='\\n')" - ] + ], + "outputs": [], + "execution_count": null }, { "cell_type": "markdown", @@ -523,9 +523,7 @@ }, { "cell_type": "code", - "execution_count": null, "metadata": {}, - "outputs": [], "source": [ "# Get the list of all aggregations in the resource\n", "aggregations = new_resource.aggregations()\n", @@ -550,7 +548,9 @@ " \n", "# Get a list of aggregations by combining field searching, filtered with \"AND\"\n", "aggregations = new_resource.aggregations(period_coverage__name=\"period_coverage name\", title=\"watersheds\")" - ] + ], + "outputs": [], + "execution_count": null }, { "cell_type": "markdown", @@ -561,9 +561,7 @@ }, { "cell_type": "code", - "execution_count": null, "metadata": {}, - "outputs": [], "source": [ "# Search for an aggregation of type time series\n", "aggregation = new_resource.aggregation(type=\"TimeSeries\")\n", @@ -573,7 +571,9 @@ "\n", "# Search for an aggregation that contains a particular file name\n", "aggregation = new_resource.aggregation(file__name=\"ODM2.sqlite\")" - ] + ], + "outputs": [], + "execution_count": null }, { "cell_type": "markdown", @@ -588,18 +588,18 @@ }, { "cell_type": "code", - "execution_count": null, "metadata": { "id": "n1FGhvLfJ6Gz" }, - "outputs": [], "source": [ "# Get the geographic feature aggregation that was created above\n", "agg = new_resource.aggregation(title=\"watersheds\")\n", "\n", "# Download the aggregation\n", "new_resource.aggregation_download(agg)" - ] + ], + "outputs": [], + "execution_count": null }, { "cell_type": "markdown", @@ -612,14 +612,14 @@ }, { "cell_type": "code", - "execution_count": null, "metadata": { "id": "8daPuEdhI7hV" }, - "outputs": [], "source": [ "!rm 'watersheds.shp.zip'" - ] + ], + "outputs": [], + "execution_count": null }, { "cell_type": "markdown", @@ -634,18 +634,18 @@ }, { "cell_type": "code", - "execution_count": null, "metadata": { "id": "gwZmuLW-FLcZ" }, - "outputs": [], "source": [ "# Get the geographic raster aggregation that was created above\n", "agg = new_resource.aggregation(title=\"logan1\")\n", "\n", "# Remove the aggregation and delete its metadata, but leave the file(s)\n", "new_resource.aggregation_remove(agg)" - ] + ], + "outputs": [], + "execution_count": null }, { "cell_type": "markdown", @@ -658,18 +658,18 @@ }, { "cell_type": "code", - "execution_count": null, "metadata": { "id": "1pVadpiFQSRo" }, - "outputs": [], "source": [ "# Get the multidimensional NetCDF aggregation that was created above\n", "agg = new_resource.aggregation(type=\"NetCDF\")\n", "\n", "# Delete the aggregation and metadata along with files within aggregation\n", "new_resource.aggregation_delete(agg)" - ] + ], + "outputs": [], + "execution_count": null } ], "metadata": { diff --git a/docs/examples/Basic_Operations.ipynb b/docs/examples/Basic_Operations.ipynb index c83dfce..1d6b9fd 100644 --- a/docs/examples/Basic_Operations.ipynb +++ b/docs/examples/Basic_Operations.ipynb @@ -28,14 +28,14 @@ }, { "cell_type": "code", - "execution_count": null, "metadata": { "id": "hzriLgMl0oJ2" }, - "outputs": [], "source": [ "!pip install hsclient" - ] + ], + "outputs": [], + "execution_count": null }, { "cell_type": "markdown", @@ -50,18 +50,18 @@ }, { "cell_type": "code", - "execution_count": null, "metadata": { "id": "3njsiY73m7_V" }, - "outputs": [], "source": [ "from hsclient import HydroShare\n", "\n", "username = 'username'\n", "password = 'password'\n", "hs = HydroShare(username, password)" - ] + ], + "outputs": [], + "execution_count": null }, { "cell_type": "markdown", @@ -72,15 +72,15 @@ }, { "cell_type": "code", - "execution_count": null, "metadata": {}, - "outputs": [], "source": [ "from hsclient import HydroShare\n", "\n", "hs = HydroShare()\n", "hs.sign_in()" - ] + ], + "outputs": [], + "execution_count": null }, { "cell_type": "markdown", @@ -105,12 +105,8 @@ } }, { + "metadata": {}, "cell_type": "code", - "execution_count": null, - "metadata": { - "id": "W9azvJ_Co87w" - }, - "outputs": [], "source": [ "# Create the new, empty resource\n", "new_resource = hs.create()\n", @@ -121,7 +117,9 @@ "\n", "# Construct a hyperlink to access the HydroShare landing page for the new resource\n", "print(f'Your new resource is available at: {new_resource.metadata.url}')" - ] + ], + "outputs": [], + "execution_count": null }, { "cell_type": "markdown", @@ -136,16 +134,16 @@ }, { "cell_type": "code", - "execution_count": null, "metadata": { "id": "-My8I_cmLOIf" }, - "outputs": [], "source": [ "# Get an existing resource using its identifier\n", "existing_resource = hs.resource(res_identifier)\n", "print(f'Just retrieved the resource with ID: {res_identifier}')" - ] + ], + "outputs": [], + "execution_count": null }, { "cell_type": "markdown", @@ -160,14 +158,14 @@ }, { "cell_type": "code", - "execution_count": null, "metadata": { "id": "G9LBisuOx5WM" }, - "outputs": [], "source": [ "new_resource.delete()" - ] + ], + "outputs": [], + "execution_count": null }, { "cell_type": "markdown", @@ -180,16 +178,16 @@ }, { "cell_type": "code", - "execution_count": null, "metadata": { "id": "Wf91WAB1H5KS" }, - "outputs": [], "source": [ "# Delete the resource using its identifier\n", "hs.resource(res_identifier).delete()\n", "print(f'Deleted resource with ID: {res_identifier}')" - ] + ], + "outputs": [], + "execution_count": null }, { "cell_type": "markdown", @@ -206,11 +204,9 @@ }, { "cell_type": "code", - "execution_count": null, "metadata": { "id": "Xqgoq9yk15e4" }, - "outputs": [], "source": [ "# Get the resource you want to download using its identifier\n", "res_identifier = '7561aa12fd824ebb8edbee05af19b910'\n", @@ -219,7 +215,9 @@ "# Download the resource as a zipped Bagit file\n", "# Pass in a file path if you want to download to a particular location\n", "res.download()" - ] + ], + "outputs": [], + "execution_count": null } ], "metadata": { diff --git a/docs/examples/File_Operations.ipynb b/docs/examples/File_Operations.ipynb index 9bac287..18b213c 100644 --- a/docs/examples/File_Operations.ipynb +++ b/docs/examples/File_Operations.ipynb @@ -28,14 +28,14 @@ }, { "cell_type": "code", - "execution_count": null, "metadata": { "id": "hzriLgMl0oJ2" }, - "outputs": [], "source": [ "!pip install hsclient" - ] + ], + "outputs": [], + "execution_count": null }, { "cell_type": "markdown", @@ -50,15 +50,15 @@ }, { "cell_type": "code", - "execution_count": null, "metadata": {}, - "outputs": [], "source": [ "from hsclient import HydroShare\n", "\n", "hs = HydroShare()\n", "hs.sign_in()" - ] + ], + "outputs": [], + "execution_count": null }, { "cell_type": "markdown", @@ -75,11 +75,9 @@ }, { "cell_type": "code", - "execution_count": null, "metadata": { "id": "W9azvJ_Co87w" }, - "outputs": [], "source": [ "# Create the new, empty resource\n", "new_resource = hs.create()\n", @@ -90,7 +88,9 @@ "\n", "# Construct a hyperlink for the new resource\n", "print(f'Your new resource is available at: {new_resource.metadata.url}')" - ] + ], + "outputs": [], + "execution_count": null }, { "cell_type": "markdown", @@ -107,18 +107,18 @@ }, { "cell_type": "code", - "execution_count": null, "metadata": { "id": "HyMe70UQApXl" }, - "outputs": [], "source": [ "# Print the title of the resource and the list of files it contains\n", "print(f'Working on: {new_resource.metadata.title}')\n", "print('File list:')\n", "for file in new_resource.files(search_aggregations=True):\n", " print(file.name)" - ] + ], + "outputs": [], + "execution_count": null }, { "cell_type": "markdown", @@ -135,11 +135,9 @@ }, { "cell_type": "code", - "execution_count": null, "metadata": { "id": "Fkff8qzx1CHZ" }, - "outputs": [], "source": [ "# Upload one or more files to your resource\n", "new_resource.file_upload('Example_Files/Data_File1.csv', 'Example_Files/Data_File2.csv')\n", @@ -148,20 +146,18 @@ "print('Updated file list after adding a file: ')\n", "for file in new_resource.files(search_aggregations=True):\n", " print(file.path)" - ] + ], + "outputs": [], + "execution_count": null }, { "cell_type": "markdown", "metadata": {}, - "source": [ - "HydroShare also allows you to create a folder heirarchy within your resource. You can use this functionality to keep your content organized, just as you would on your own computer. You can upload files to specific folders within the resource. Paths to folders are specified relative to the \"content\" directory of the resource." - ] + "source": "HydroShare also allows you to create a folder hierarchy within your resource. You can use this functionality to keep your content organized, just as you would on your own computer. You can upload files to specific folders within the resource. Paths to folders are specified relative to the \"content\" directory of the resource." }, { "cell_type": "code", - "execution_count": null, "metadata": {}, - "outputs": [], "source": [ "# First create a new folder\n", "new_resource.folder_create('New_Folder')\n", @@ -173,7 +169,9 @@ "print('Updated file list after adding a file: ')\n", "for file in new_resource.files(search_aggregations=True):\n", " print(file.path)" - ] + ], + "outputs": [], + "execution_count": null }, { "cell_type": "markdown", @@ -195,9 +193,7 @@ }, { "cell_type": "code", - "execution_count": null, "metadata": {}, - "outputs": [], "source": [ "# Get a list of the files in the resource that are not part of an aggregation\n", "file_list = new_resource.files()\n", @@ -232,7 +228,9 @@ "file_list = new_resource.files(folder='New_Folder', extension='.csv')\n", "print('All files with a .csv file extension in a particular folder:')\n", "print(*file_list, sep='\\n')" - ] + ], + "outputs": [], + "execution_count": null }, { "cell_type": "markdown", @@ -245,9 +243,7 @@ }, { "cell_type": "code", - "execution_count": null, "metadata": {}, - "outputs": [], "source": [ "# Get a single file using its path relative to the resource content directory\n", "file = new_resource.file(path='New_Folder/Data_File2.csv')\n", @@ -262,7 +258,9 @@ "file = new_resource.file(name='Data_File2.csv')\n", "print('File retrieved using name:')\n", "print(file)" - ] + ], + "outputs": [], + "execution_count": null }, { "cell_type": "markdown", @@ -275,9 +273,7 @@ }, { "cell_type": "code", - "execution_count": null, "metadata": {}, - "outputs": [], "source": [ "# Search for a file within a resource\n", "file = new_resource.file(path='New_Folder/Data_File2.csv')\n", @@ -289,7 +285,9 @@ "print(f'File path: {file.path}')\n", "print(f'File url_path: {file.url}')\n", "print(f'File checksum: {file.checksum}')" - ] + ], + "outputs": [], + "execution_count": null }, { "cell_type": "markdown", @@ -302,9 +300,7 @@ }, { "cell_type": "code", - "execution_count": null, "metadata": {}, - "outputs": [], "source": [ "# Get a file to rename - use the relative path to the file to make sure you have the right one\n", "file = new_resource.file(path='Data_File2.csv')\n", @@ -316,7 +312,9 @@ "print('Updated file list after renaming a file: ')\n", "for file in new_resource.files(search_aggregations=True):\n", " print(file.path)" - ] + ], + "outputs": [], + "execution_count": null }, { "cell_type": "markdown", @@ -327,9 +325,7 @@ }, { "cell_type": "code", - "execution_count": null, "metadata": {}, - "outputs": [], "source": [ "# Get a file to move\n", "file = new_resource.file(path='Data_File1.csv')\n", @@ -341,7 +337,9 @@ "print('Updated file list after adding a file: ')\n", "for file in new_resource.files(search_aggregations=True):\n", " print(file.path)" - ] + ], + "outputs": [], + "execution_count": null }, { "cell_type": "markdown", @@ -358,18 +356,18 @@ }, { "cell_type": "code", - "execution_count": null, "metadata": { "id": "Mj4nEDY1_QOr" }, - "outputs": [], "source": [ "# Download a single file from a resource\n", "# Note that if you have multiple files within the same resource that have the same name,\n", "# and you want a particular file, you need to specify the relative path to the specific file\n", "file = new_resource.file(path='New_Folder/Data_File1.csv')\n", "new_resource.file_download(file)" - ] + ], + "outputs": [], + "execution_count": null }, { "cell_type": "markdown", @@ -382,14 +380,14 @@ }, { "cell_type": "code", - "execution_count": null, "metadata": { "id": "9cz_dgOsLb3n" }, - "outputs": [], "source": [ "!rm 'Data_File1.csv'" - ] + ], + "outputs": [], + "execution_count": null }, { "cell_type": "markdown", @@ -404,11 +402,9 @@ }, { "cell_type": "code", - "execution_count": null, "metadata": { "id": "aus1oUqoEJcu" }, - "outputs": [], "source": [ "# Specify the file you want to delete\n", "file = new_resource.file(path='New_Folder/Data_File2.csv')\n", @@ -419,7 +415,9 @@ "print('Updated file list after removing file: ')\n", "for file in new_resource.files(search_aggregations=True):\n", " print(file.path)" - ] + ], + "outputs": [], + "execution_count": null }, { "cell_type": "markdown", diff --git a/docs/examples/Metadata_Operations.ipynb b/docs/examples/Metadata_Operations.ipynb index 4fcb707..6d68c46 100644 --- a/docs/examples/Metadata_Operations.ipynb +++ b/docs/examples/Metadata_Operations.ipynb @@ -28,14 +28,14 @@ }, { "cell_type": "code", - "execution_count": null, "metadata": { "id": "hzriLgMl0oJ2" }, - "outputs": [], "source": [ "!pip install hsclient" - ] + ], + "outputs": [], + "execution_count": null }, { "cell_type": "markdown", @@ -50,17 +50,17 @@ }, { "cell_type": "code", - "execution_count": null, "metadata": { "id": "3njsiY73m7_V" }, - "outputs": [], "source": [ "from hsclient import HydroShare\n", "\n", "hs = HydroShare()\n", "hs.sign_in()" - ] + ], + "outputs": [], + "execution_count": null }, { "cell_type": "markdown", @@ -77,11 +77,9 @@ }, { "cell_type": "code", - "execution_count": null, "metadata": { "id": "W9azvJ_Co87w" }, - "outputs": [], "source": [ "# Create the new, empty resource\n", "new_resource = hs.create()\n", @@ -92,7 +90,9 @@ "\n", "# Construct a hyperlink to access the HydroShare landing page for the new resource\n", "print(f'Your new resource is available at: {new_resource.metadata.url}')" - ] + ], + "outputs": [], + "execution_count": null }, { "cell_type": "markdown", @@ -120,11 +120,9 @@ }, { "cell_type": "code", - "execution_count": null, "metadata": { "id": "QTJIRqu2K42K" }, - "outputs": [], "source": [ "# Set the Title for the resource\n", "new_resource.metadata.title = 'Resource for Testing the hsclient HydroShare Python Client'\n", @@ -143,7 +141,9 @@ "# Print the title just added to the resource\n", "print(f'Title: {new_resource.metadata.title}')\n", "print(f'Abstract: {new_resource.metadata.abstract}')" - ] + ], + "outputs": [], + "execution_count": null }, { "cell_type": "markdown", @@ -158,11 +158,9 @@ }, { "cell_type": "code", - "execution_count": null, "metadata": { "id": "AkwznZOaso_r" }, - "outputs": [], "source": [ "# Create subject keywords for the resource using a list of strings\n", "new_resource.metadata.subjects = ['hsclient', 'Python', 'HydroShare', 'Another Keyword']\n", @@ -180,7 +178,9 @@ "print('The list of keywords for the resource includes:')\n", "for keyword in new_resource.metadata.subjects:\n", " print(keyword)" - ] + ], + "outputs": [], + "execution_count": null }, { "cell_type": "markdown", @@ -195,11 +195,9 @@ }, { "cell_type": "code", - "execution_count": null, "metadata": { "id": "S1uPNyt3bLdl" }, - "outputs": [], "source": [ "# Import the required metadata classes for coverage objects\n", "from hsmodels.schemas.fields import BoxCoverage, PointCoverage, PeriodCoverage\n", @@ -244,7 +242,9 @@ "# Print the spatial coverage information\n", "print('\\nSpatial Coverage:')\n", "print(new_resource.metadata.spatial_coverage)" - ] + ], + "outputs": [], + "execution_count": null }, { "cell_type": "markdown", @@ -259,11 +259,9 @@ }, { "cell_type": "code", - "execution_count": null, "metadata": { "id": "CNVPngHLSGCU" }, - "outputs": [], "source": [ "# Add an extended metadata element as a key-value pair\n", "new_resource.metadata.additional_metadata['New Element Key'] = 'Text value of new element key.'\n", @@ -288,7 +286,9 @@ "print('The extended metadata elements for the resource include:')\n", "for key, value in new_resource.metadata.additional_metadata.items():\n", " print(f'{key}: {value}')" - ] + ], + "outputs": [], + "execution_count": null }, { "cell_type": "markdown", @@ -303,11 +303,9 @@ }, { "cell_type": "code", - "execution_count": null, "metadata": { "id": "YmP0zLVDzdyL" }, - "outputs": [], "source": [ "# Import the required metadata class for a Relation object\n", "from hsmodels.schemas.fields import Relation\n", @@ -346,7 +344,9 @@ "print('The list of Related Resources includes:')\n", "for relatedResource in new_resource.metadata.relations:\n", " print(f'{relatedResource.type.value}: {relatedResource.value}')" - ] + ], + "outputs": [], + "execution_count": null }, { "cell_type": "markdown", @@ -361,11 +361,9 @@ }, { "cell_type": "code", - "execution_count": null, "metadata": { "id": "gT0bgrHZbB1Q" }, - "outputs": [], "source": [ "# Import the required metadata class for an AwardInfo object\n", "from hsmodels.schemas.fields import AwardInfo\n", @@ -392,7 +390,9 @@ "print('Funding sources added: ')\n", "for award in new_resource.metadata.awards:\n", " print(f'Award Title: {award.title}')" - ] + ], + "outputs": [], + "execution_count": null }, { "cell_type": "markdown", @@ -407,11 +407,9 @@ }, { "cell_type": "code", - "execution_count": null, "metadata": { "id": "RzHEDCTlWLat" }, - "outputs": [], "source": [ "# Import the required metadata class for a Creator object\n", "from hsmodels.schemas.fields import Creator\n", @@ -464,7 +462,9 @@ " print(creator.organization)\n", " else:\n", " print(creator.name)" - ] + ], + "outputs": [], + "execution_count": null }, { "cell_type": "markdown", @@ -477,11 +477,9 @@ }, { "cell_type": "code", - "execution_count": null, "metadata": { "id": "bJgVpwgEoCfH" }, - "outputs": [], "source": [ "# Change the order of the Creators in the list\n", "creatorOrder = [3, 2, 0, 1, 4]\n", @@ -497,7 +495,9 @@ " print(creator.organization)\n", " else:\n", " print(creator.name)" - ] + ], + "outputs": [], + "execution_count": null }, { "cell_type": "markdown", @@ -510,18 +510,18 @@ }, { "cell_type": "code", - "execution_count": null, "metadata": { "id": "s34w7lEqY2sE" }, - "outputs": [], "source": [ "# Example of removing all but the first creator\n", "del new_resource.metadata.creators[1:]\n", "new_resource.save()\n", "\n", "print(f'Number of remaining creators: {len(new_resource.metadata.creators)}')" - ] + ], + "outputs": [], + "execution_count": null }, { "cell_type": "markdown", @@ -536,11 +536,9 @@ }, { "cell_type": "code", - "execution_count": null, "metadata": { "id": "Vmw7dgC9a9Za" }, - "outputs": [], "source": [ "# Import the required metadata class for a Contributor object\n", "from hsmodels.schemas.fields import Contributor\n", @@ -583,7 +581,9 @@ "print('The list of Contributors includes: ')\n", "for Contributor in new_resource.metadata.contributors:\n", " print(Contributor.name)" - ] + ], + "outputs": [], + "execution_count": null }, { "cell_type": "markdown", @@ -596,18 +596,18 @@ }, { "cell_type": "code", - "execution_count": null, "metadata": { "id": "oM1U3TUaotjA" }, - "outputs": [], "source": [ "# Clear the list of Contributors and save to HydroShare\n", "new_resource.metadata.contributors.clear()\n", "new_resource.save()\n", "\n", "print(f'Number of remaining Contributors: {len(new_resource.metadata.contributors)}')" - ] + ], + "outputs": [], + "execution_count": null }, { "cell_type": "markdown", @@ -622,11 +622,9 @@ }, { "cell_type": "code", - "execution_count": null, "metadata": { "id": "G7ejpRSpEIdn" }, - "outputs": [], "source": [ "# Import the required metadata class for a Rights object\n", "from hsmodels.schemas.fields import Rights\n", @@ -654,18 +652,20 @@ "# Print the rights statement:\n", "print(new_resource.metadata.rights.statement)\n", "print(new_resource.metadata.rights.url)" - ] + ], + "outputs": [], + "execution_count": null }, { "cell_type": "code", - "execution_count": null, - "outputs": [], "source": [ "# TODO: Related geospatial features is not implemented yet" ], "metadata": { "collapsed": false - } + }, + "outputs": [], + "execution_count": null } ], "metadata": {