Repository: opendatacube/datacube-core

Issue:
Command `datacube metadata update` doesn't work with URLs
### Expected behaviour

Running `datacube metadata add http://example.com/metadata.yaml` works, but if you subsequently run `datacube metadata update http://example.com/metadata.yaml` it fails with something like the below error.

```
No such file or directory: '/https:/raw.githubusercontent.com/GeoscienceAustralia/digitalearthau/develop/digitalearthau/config/metadata-types.odc-type.yaml'>

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/env/bin/datacube", line 8, in <module>
    sys.exit(cli())
  File "/env/lib/python3.6/site-packages/click/core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "/env/lib/python3.6/site-packages/click/core.py", line 782, in main
    rv = self.invoke(ctx)
  File "/env/lib/python3.6/site-packages/click/core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/env/lib/python3.6/site-packages/click/core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/env/lib/python3.6/site-packages/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/env/lib/python3.6/site-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/env/lib/python3.6/site-packages/datacube/ui/click.py", line 197, in new_func
    return f(parsed_config, *args, **kwargs)
  File "/env/lib/python3.6/site-packages/datacube/ui/click.py", line 225, in with_index
    return f(index, *args, **kwargs)
  File "/env/lib/python3.6/site-packages/datacube/scripts/metadata.py", line 69, in update_metadata_types
    for descriptor_path, parsed_doc in read_documents(*(Path(f) for f in files)):
  File "/env/lib/python3.6/site-packages/datacube/utils/documents.py", line 174, in read_documents
    raise InvalidDocException('Failed to load %s: %s' % (path, e))
datacube.utils.documents.InvalidDocException: Failed to load https:/raw.githubusercontent.com/GeoscienceAustralia/digitalearthau/develop/digitalearthau/config/metadata-types.odc-type.yaml: <urlopen error [Errno 2] No such file or directory: '/https:/raw.githubusercontent.com/GeoscienceAustralia/digitalearthau/develop/digitalearthau/config/metadata-types.odc-type.yaml'>
```


### Environment information

> Open Data Cube core, version 1.7+262.g1cf3cea8



Discussion:

Resolving patch:
diff --git a/datacube/scripts/metadata.py b/datacube/scripts/metadata.py
--- a/datacube/scripts/metadata.py
+++ b/datacube/scripts/metadata.py
@@ -66,7 +66,7 @@ def update_metadata_types(index: Index, allow_unsafe: bool, allow_exclusive_lock
     (An unsafe change is anything that may potentially make the metadata type
     incompatible with existing ones of the same name)
     """
-    for descriptor_path, parsed_doc in read_documents(*(Path(f) for f in files)):
+    for descriptor_path, parsed_doc in read_documents(*files):
         try:
             type_ = index.metadata_types.from_doc(parsed_doc)
         except InvalidDocException as e:
diff --git a/datacube/scripts/product.py b/datacube/scripts/product.py
--- a/datacube/scripts/product.py
+++ b/datacube/scripts/product.py
@@ -79,7 +79,7 @@ def update_products(index: Index, allow_unsafe: bool, allow_exclusive_lock: bool
     incompatible with existing datasets of that type)
     """
     failures = 0
-    for descriptor_path, parsed_doc in read_documents(*(Path(f) for f in files)):
+    for descriptor_path, parsed_doc in read_documents(*files):
         try:
             type_ = index.products.from_doc(parsed_doc)
         except InvalidDocException as e:
diff --git a/datacube/testutils/io.py b/datacube/testutils/io.py
--- a/datacube/testutils/io.py
+++ b/datacube/testutils/io.py
@@ -365,5 +365,4 @@ def rio_slurp_xarray(fname, *args, rgb='auto', **kw):
                      dims=dims,
                      coords=mm.gbox.xr_coords(),
                      attrs=dict(
-                         crs=mm.gbox.crs,
                          nodata=mm.nodata))


Test patch: