dtool-http 0.5.2__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- dtool_http/__init__.py +16 -0
- dtool_http/publish.py +53 -0
- dtool_http/server.py +130 -0
- dtool_http/storagebroker.py +195 -0
- dtool_http/version.py +21 -0
- dtool_http-0.5.2.dist-info/METADATA +128 -0
- dtool_http-0.5.2.dist-info/RECORD +11 -0
- dtool_http-0.5.2.dist-info/WHEEL +5 -0
- dtool_http-0.5.2.dist-info/entry_points.txt +7 -0
- dtool_http-0.5.2.dist-info/licenses/LICENSE.rst +22 -0
- dtool_http-0.5.2.dist-info/top_level.txt +1 -0
dtool_http/__init__.py
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"""dtool_http package."""
|
|
2
|
+
|
|
3
|
+
import logging
|
|
4
|
+
|
|
5
|
+
try:
|
|
6
|
+
from importlib.metadata import version, PackageNotFoundError
|
|
7
|
+
except ModuleNotFoundError:
|
|
8
|
+
from importlib_metadata import version, PackageNotFoundError
|
|
9
|
+
|
|
10
|
+
try:
|
|
11
|
+
__version__ = version(__name__)
|
|
12
|
+
except PackageNotFoundError:
|
|
13
|
+
# package is not installed
|
|
14
|
+
pass
|
|
15
|
+
|
|
16
|
+
logger = logging.getLogger(__name__)
|
dtool_http/publish.py
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"""Enable HTTP access to a dataset."""
|
|
2
|
+
|
|
3
|
+
import argparse
|
|
4
|
+
import sys
|
|
5
|
+
|
|
6
|
+
import dtoolcore
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def publish(dataset_uri):
|
|
10
|
+
"""Return access URL to HTTP enabled (published) dataset.
|
|
11
|
+
|
|
12
|
+
Exits with error code 1 if the dataset_uri is not a dataset.
|
|
13
|
+
Exits with error code 2 if the dataset cannot be HTTP enabled.
|
|
14
|
+
"""
|
|
15
|
+
|
|
16
|
+
try:
|
|
17
|
+
dataset = dtoolcore.DataSet.from_uri(dataset_uri)
|
|
18
|
+
except dtoolcore.DtoolCoreTypeError:
|
|
19
|
+
print("Not a dataset: {}".format(dataset_uri))
|
|
20
|
+
sys.exit(1)
|
|
21
|
+
|
|
22
|
+
try:
|
|
23
|
+
access_uri = dataset._storage_broker.http_enable()
|
|
24
|
+
except AttributeError:
|
|
25
|
+
print(
|
|
26
|
+
"Datasets of type '{}' cannot be published using HTTP".format(
|
|
27
|
+
dataset._storage_broker.key)
|
|
28
|
+
)
|
|
29
|
+
sys.exit(2)
|
|
30
|
+
|
|
31
|
+
return access_uri
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
def cli():
|
|
35
|
+
"""Command line utility to HTTP enable (publish) a dataset."""
|
|
36
|
+
parser = argparse.ArgumentParser(description=__doc__)
|
|
37
|
+
parser.add_argument(
|
|
38
|
+
"dataset_uri",
|
|
39
|
+
help="Dtool dataset URI"
|
|
40
|
+
)
|
|
41
|
+
parser.add_argument(
|
|
42
|
+
"-q",
|
|
43
|
+
"--quiet",
|
|
44
|
+
action="store_true",
|
|
45
|
+
help="Only return the http URI"
|
|
46
|
+
)
|
|
47
|
+
args = parser.parse_args()
|
|
48
|
+
access_uri = publish(args.dataset_uri)
|
|
49
|
+
|
|
50
|
+
if args.quiet:
|
|
51
|
+
print(access_uri)
|
|
52
|
+
else:
|
|
53
|
+
print("Dataset accessible at: {}".format(access_uri))
|
dtool_http/server.py
ADDED
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
"""Basic Dtool HTTP server."""
|
|
2
|
+
|
|
3
|
+
import argparse
|
|
4
|
+
import os
|
|
5
|
+
import json
|
|
6
|
+
|
|
7
|
+
from http.server import HTTPServer, SimpleHTTPRequestHandler
|
|
8
|
+
|
|
9
|
+
import dtoolcore
|
|
10
|
+
from dtoolcore.utils import urlunparse
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class DtoolHTTPRequestHandler(SimpleHTTPRequestHandler):
|
|
14
|
+
"""Subclass of standard library SimpleHTTPRequestHandler."""
|
|
15
|
+
|
|
16
|
+
def generate_url(self, suffix):
|
|
17
|
+
"""Return URL by combining server details with a path suffix."""
|
|
18
|
+
url_base_path = os.path.dirname(self.path)
|
|
19
|
+
netloc = "{}:{}".format(*self.server.server_address)
|
|
20
|
+
return urlunparse((
|
|
21
|
+
"http",
|
|
22
|
+
netloc,
|
|
23
|
+
url_base_path + "/" + suffix,
|
|
24
|
+
"", "", ""))
|
|
25
|
+
|
|
26
|
+
def generate_item_urls(self):
|
|
27
|
+
"""Return dict with identifier/URL pairs for the dataset items."""
|
|
28
|
+
item_urls = {}
|
|
29
|
+
for i in self.dataset.identifiers:
|
|
30
|
+
relpath = self.dataset.item_properties(i)["relpath"]
|
|
31
|
+
url = self.generate_url("data/" + relpath)
|
|
32
|
+
item_urls[i] = url
|
|
33
|
+
return item_urls
|
|
34
|
+
|
|
35
|
+
def generate_overlay_urls(self):
|
|
36
|
+
"""Return dict with overlay/URL pairs for the dataset overlays."""
|
|
37
|
+
overlays = {}
|
|
38
|
+
for o in self.dataset.list_overlay_names():
|
|
39
|
+
url = self.generate_url(".dtool/overlays/{}.json".format(o))
|
|
40
|
+
overlays[o] = url
|
|
41
|
+
return overlays
|
|
42
|
+
|
|
43
|
+
def generate_annotation_urls(self):
|
|
44
|
+
"""Return dict with annotation/URL pairs for the annotations."""
|
|
45
|
+
annotations = {}
|
|
46
|
+
for a in self.dataset.list_annotation_names():
|
|
47
|
+
url = self.generate_url(".dtool/annotations/{}.json".format(a))
|
|
48
|
+
annotations[a] = url
|
|
49
|
+
return annotations
|
|
50
|
+
|
|
51
|
+
def generate_tags_list(self):
|
|
52
|
+
"""Return list with dataset tags."""
|
|
53
|
+
return self.dataset.list_tags()
|
|
54
|
+
|
|
55
|
+
def generate_http_manifest(self):
|
|
56
|
+
"""Return http manifest.
|
|
57
|
+
|
|
58
|
+
The http manifest is the resource that defines a dataset as HTTP
|
|
59
|
+
enabled (published).
|
|
60
|
+
"""
|
|
61
|
+
base_path = os.path.dirname(self.translate_path(self.path))
|
|
62
|
+
self.dataset = dtoolcore.DataSet.from_uri(base_path)
|
|
63
|
+
|
|
64
|
+
admin_metadata_fpath = os.path.join(base_path, ".dtool", "dtool")
|
|
65
|
+
with open(admin_metadata_fpath) as fh:
|
|
66
|
+
admin_metadata = json.load(fh)
|
|
67
|
+
|
|
68
|
+
http_manifest = {
|
|
69
|
+
"admin_metadata": admin_metadata,
|
|
70
|
+
"manifest_url": self.generate_url(".dtool/manifest.json"),
|
|
71
|
+
"readme_url": self.generate_url("README.yml"),
|
|
72
|
+
"overlays": self.generate_overlay_urls(),
|
|
73
|
+
"annotations": self.generate_annotation_urls(),
|
|
74
|
+
"tags": self.generate_tags_list(),
|
|
75
|
+
"item_urls": self.generate_item_urls()
|
|
76
|
+
}
|
|
77
|
+
return bytes(json.dumps(http_manifest), "utf-8")
|
|
78
|
+
|
|
79
|
+
def do_GET(self):
|
|
80
|
+
"""Override inherited do_GET method.
|
|
81
|
+
|
|
82
|
+
Include logic for returning a http manifest when the URL ends with
|
|
83
|
+
"http_manifest.json".
|
|
84
|
+
"""
|
|
85
|
+
if self.path.endswith("http_manifest.json"):
|
|
86
|
+
try:
|
|
87
|
+
manifest = self.generate_http_manifest()
|
|
88
|
+
self.send_response(200)
|
|
89
|
+
self.end_headers()
|
|
90
|
+
self.wfile.write(manifest)
|
|
91
|
+
except dtoolcore.DtoolCoreTypeError:
|
|
92
|
+
self.send_response(400)
|
|
93
|
+
self.end_headers()
|
|
94
|
+
|
|
95
|
+
else:
|
|
96
|
+
super(DtoolHTTPRequestHandler, self).do_GET()
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
class DtoolHTTPServer(HTTPServer):
|
|
100
|
+
"""Subclass of standard library HTTPServer."""
|
|
101
|
+
pass
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
def serve_dtool_directory(directory, port):
|
|
105
|
+
"""Serve the datasets in a directory over HTTP."""
|
|
106
|
+
os.chdir(directory)
|
|
107
|
+
server_address = ("localhost", port)
|
|
108
|
+
httpd = DtoolHTTPServer(server_address, DtoolHTTPRequestHandler)
|
|
109
|
+
httpd.serve_forever()
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
def cli():
|
|
113
|
+
"""Command line utility for serving datasets in a directory over HTTP."""
|
|
114
|
+
parser = argparse.ArgumentParser(description=__doc__)
|
|
115
|
+
parser.add_argument(
|
|
116
|
+
"dataset_directory",
|
|
117
|
+
help="Directory with datasets to be served"
|
|
118
|
+
)
|
|
119
|
+
parser.add_argument(
|
|
120
|
+
"-p",
|
|
121
|
+
"--port",
|
|
122
|
+
type=int,
|
|
123
|
+
default=8081,
|
|
124
|
+
help="Port to serve datasets on (default 8081)"
|
|
125
|
+
)
|
|
126
|
+
args = parser.parse_args()
|
|
127
|
+
if not os.path.isdir(args.dataset_directory):
|
|
128
|
+
parser.error("Not a directory: {}".format(args.dataset_directory))
|
|
129
|
+
|
|
130
|
+
serve_dtool_directory(args.dataset_directory, args.port)
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
"""HTTP(S) storage broker."""
|
|
2
|
+
|
|
3
|
+
import logging
|
|
4
|
+
import os
|
|
5
|
+
import json
|
|
6
|
+
import shutil
|
|
7
|
+
import requests
|
|
8
|
+
|
|
9
|
+
from dtoolcore.utils import (
|
|
10
|
+
get_config_value,
|
|
11
|
+
mkdir_parents,
|
|
12
|
+
generous_parse_uri,
|
|
13
|
+
DEFAULT_CACHE_PATH,
|
|
14
|
+
)
|
|
15
|
+
|
|
16
|
+
logger = logging.getLogger(__name__)
|
|
17
|
+
|
|
18
|
+
HTTP_MANIFEST_KEY = 'http_manifest.json'
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
class HTTPError(RuntimeError):
|
|
22
|
+
pass
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
class HTTPStorageBroker(object):
|
|
26
|
+
"""
|
|
27
|
+
Storage broker to interact with datasets over HTTP in a read only fashion.
|
|
28
|
+
"""
|
|
29
|
+
|
|
30
|
+
key = "http"
|
|
31
|
+
|
|
32
|
+
def __init__(self, uri, admin_metadata, config_path=None):
|
|
33
|
+
|
|
34
|
+
parse_result = generous_parse_uri(uri)
|
|
35
|
+
|
|
36
|
+
# Get potential query signature for Azure/S3
|
|
37
|
+
self._signature = parse_result.query
|
|
38
|
+
|
|
39
|
+
# Base URI may be redirected to a different location
|
|
40
|
+
self._uri = self._get_base_uri(parse_result)
|
|
41
|
+
parse_result = generous_parse_uri(self._uri)
|
|
42
|
+
|
|
43
|
+
self.scheme = parse_result.scheme
|
|
44
|
+
self.netloc = parse_result.netloc
|
|
45
|
+
self.uuid = parse_result.path[1:]
|
|
46
|
+
|
|
47
|
+
http_manifest_url = parse_result._replace(
|
|
48
|
+
path=parse_result.path + '/' + HTTP_MANIFEST_KEY,
|
|
49
|
+
query=self._signature).geturl()
|
|
50
|
+
|
|
51
|
+
self.http_manifest = self._get_json_from_url(
|
|
52
|
+
http_manifest_url
|
|
53
|
+
)
|
|
54
|
+
|
|
55
|
+
self._cache_abspath = get_config_value(
|
|
56
|
+
"DTOOL_CACHE_DIRECTORY",
|
|
57
|
+
config_path=config_path,
|
|
58
|
+
default=DEFAULT_CACHE_PATH
|
|
59
|
+
)
|
|
60
|
+
|
|
61
|
+
# Helper functions
|
|
62
|
+
|
|
63
|
+
def _get_base_uri(self, parse_result):
|
|
64
|
+
r = requests.get(parse_result._replace(query="").geturl())
|
|
65
|
+
if r.status_code != 301:
|
|
66
|
+
logger.info("Dataset moved, redirecting to: {}".format(r.url))
|
|
67
|
+
return r.url
|
|
68
|
+
|
|
69
|
+
def _get_request(self, url, stream=False):
|
|
70
|
+
r = requests.get(url, stream=stream)
|
|
71
|
+
logger.info("Response status code: {}".format(r.status_code))
|
|
72
|
+
|
|
73
|
+
if r.status_code != 200:
|
|
74
|
+
raise(HTTPError(r.status_code))
|
|
75
|
+
|
|
76
|
+
return r
|
|
77
|
+
|
|
78
|
+
def _get_text_from_url(self, url):
|
|
79
|
+
|
|
80
|
+
r = self._get_request(url)
|
|
81
|
+
|
|
82
|
+
return r.text
|
|
83
|
+
|
|
84
|
+
def _get_json_from_url(self, url):
|
|
85
|
+
text = self._get_text_from_url(url)
|
|
86
|
+
|
|
87
|
+
return json.loads(text)
|
|
88
|
+
|
|
89
|
+
# Functions to allow dataset retrieval
|
|
90
|
+
def get_admin_metadata(self):
|
|
91
|
+
"""Return administrative metadata as a dictionary."""
|
|
92
|
+
return self.http_manifest["admin_metadata"]
|
|
93
|
+
|
|
94
|
+
def get_manifest(self):
|
|
95
|
+
"""Return the manifest as a dictionary."""
|
|
96
|
+
url = self.http_manifest["manifest_url"]
|
|
97
|
+
return self._get_json_from_url(url)
|
|
98
|
+
|
|
99
|
+
def get_readme_content(self):
|
|
100
|
+
"""Return content of the README file as a string."""
|
|
101
|
+
url = self.http_manifest["readme_url"]
|
|
102
|
+
return self._get_text_from_url(url)
|
|
103
|
+
|
|
104
|
+
def has_admin_metadata(self):
|
|
105
|
+
"""Return True if the administrative metadata exists.
|
|
106
|
+
|
|
107
|
+
This is the definition of being a "dataset".
|
|
108
|
+
"""
|
|
109
|
+
return "admin_metadata" in self.http_manifest
|
|
110
|
+
|
|
111
|
+
def get_item_abspath(self, identifier):
|
|
112
|
+
"""Return absolute path at which item content can be accessed.
|
|
113
|
+
|
|
114
|
+
:param identifier: item identifier
|
|
115
|
+
:returns: absolute path from which the item content can be accessed
|
|
116
|
+
"""
|
|
117
|
+
|
|
118
|
+
dataset_cache_abspath = os.path.join(
|
|
119
|
+
self._cache_abspath,
|
|
120
|
+
self.uuid
|
|
121
|
+
)
|
|
122
|
+
mkdir_parents(dataset_cache_abspath)
|
|
123
|
+
|
|
124
|
+
manifest = self.get_manifest()
|
|
125
|
+
relpath = manifest['items'][identifier]['relpath']
|
|
126
|
+
_, ext = os.path.splitext(relpath)
|
|
127
|
+
|
|
128
|
+
local_item_abspath = os.path.join(
|
|
129
|
+
dataset_cache_abspath,
|
|
130
|
+
identifier + ext
|
|
131
|
+
)
|
|
132
|
+
|
|
133
|
+
if not os.path.isfile(local_item_abspath):
|
|
134
|
+
|
|
135
|
+
url = self.http_manifest["item_urls"][identifier]
|
|
136
|
+
|
|
137
|
+
r = self._get_request(url, stream=True)
|
|
138
|
+
tmp_local_item_abspath = local_item_abspath + ".tmp"
|
|
139
|
+
with open(tmp_local_item_abspath, 'wb') as f:
|
|
140
|
+
shutil.copyfileobj(r.raw, f)
|
|
141
|
+
os.rename(tmp_local_item_abspath, local_item_abspath)
|
|
142
|
+
|
|
143
|
+
return local_item_abspath
|
|
144
|
+
|
|
145
|
+
def get_overlay(self, overlay_name):
|
|
146
|
+
"""Return overlay as a dictionary.
|
|
147
|
+
|
|
148
|
+
:param overlay_name: name of the overlay
|
|
149
|
+
:returns: overlay as a dictionary
|
|
150
|
+
"""
|
|
151
|
+
url = self.http_manifest["overlays"][overlay_name]
|
|
152
|
+
return self._get_json_from_url(url)
|
|
153
|
+
|
|
154
|
+
def get_annotation(self, annotation_name):
|
|
155
|
+
"""Return annotation.
|
|
156
|
+
|
|
157
|
+
:param overlay_name: name of the annotation
|
|
158
|
+
:returns: annotation
|
|
159
|
+
"""
|
|
160
|
+
url = self.http_manifest["annotations"][annotation_name]
|
|
161
|
+
return self._get_json_from_url(url)
|
|
162
|
+
|
|
163
|
+
def list_overlay_names(self):
|
|
164
|
+
"""Return list of overlay names."""
|
|
165
|
+
if "overlays" not in self.http_manifest:
|
|
166
|
+
return []
|
|
167
|
+
return self.http_manifest["overlays"].keys()
|
|
168
|
+
|
|
169
|
+
def list_annotation_names(self):
|
|
170
|
+
"""Return list of annotation names."""
|
|
171
|
+
if "annotations" not in self.http_manifest:
|
|
172
|
+
return []
|
|
173
|
+
return self.http_manifest["annotations"].keys()
|
|
174
|
+
|
|
175
|
+
def list_tags(self):
|
|
176
|
+
"""Return list of annotation names."""
|
|
177
|
+
if "tags" not in self.http_manifest:
|
|
178
|
+
return []
|
|
179
|
+
return self.http_manifest["tags"]
|
|
180
|
+
|
|
181
|
+
def list_dataset_uris(self, base_uri, CONFIG_PATH):
|
|
182
|
+
"""Return list of datasets in base uri."""
|
|
183
|
+
return []
|
|
184
|
+
|
|
185
|
+
def http_enable(self):
|
|
186
|
+
"""Return the URI from which the dataset can be accessed via HTTP."""
|
|
187
|
+
return self._uri
|
|
188
|
+
|
|
189
|
+
|
|
190
|
+
class HTTPSStorageBroker(HTTPStorageBroker):
|
|
191
|
+
"""
|
|
192
|
+
Storage broker to interact with datasets over HTTPS in a read only fashion.
|
|
193
|
+
"""
|
|
194
|
+
|
|
195
|
+
key = "https"
|
dtool_http/version.py
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# file generated by setuptools-scm
|
|
2
|
+
# don't change, don't track in version control
|
|
3
|
+
|
|
4
|
+
__all__ = ["__version__", "__version_tuple__", "version", "version_tuple"]
|
|
5
|
+
|
|
6
|
+
TYPE_CHECKING = False
|
|
7
|
+
if TYPE_CHECKING:
|
|
8
|
+
from typing import Tuple
|
|
9
|
+
from typing import Union
|
|
10
|
+
|
|
11
|
+
VERSION_TUPLE = Tuple[Union[int, str], ...]
|
|
12
|
+
else:
|
|
13
|
+
VERSION_TUPLE = object
|
|
14
|
+
|
|
15
|
+
version: str
|
|
16
|
+
__version__: str
|
|
17
|
+
__version_tuple__: VERSION_TUPLE
|
|
18
|
+
version_tuple: VERSION_TUPLE
|
|
19
|
+
|
|
20
|
+
__version__ = version = '0.5.2'
|
|
21
|
+
__version_tuple__ = version_tuple = (0, 5, 2)
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: dtool-http
|
|
3
|
+
Version: 0.5.2
|
|
4
|
+
Summary: Add HTTP read only dataset support to dtool
|
|
5
|
+
Author-email: Tjelvar Olsson <tjelvar.olsson@gmail.com>
|
|
6
|
+
Project-URL: Documentation, https://github.com/jic-dtool/dtool-http/blob/master/README.rst
|
|
7
|
+
Project-URL: Repository, https://github.com/jic-dtool/dtool-http
|
|
8
|
+
Project-URL: Changelog, https://github.com/jic-dtool/dtool-http/blob/master/CHANGELOG.rst
|
|
9
|
+
Description-Content-Type: text/x-rst
|
|
10
|
+
License-File: LICENSE.rst
|
|
11
|
+
Requires-Dist: dtoolcore>=3.13
|
|
12
|
+
Requires-Dist: requests
|
|
13
|
+
Provides-Extra: test
|
|
14
|
+
Requires-Dist: pytest; extra == "test"
|
|
15
|
+
Requires-Dist: pytest-cov; extra == "test"
|
|
16
|
+
Requires-Dist: pytz; extra == "test"
|
|
17
|
+
Dynamic: license-file
|
|
18
|
+
|
|
19
|
+
Add HTTP support to dtool for read only access to datasets
|
|
20
|
+
==========================================================
|
|
21
|
+
|
|
22
|
+
.. |dtool| image:: https://github.com/jic-dtool/dtool-http/blob/master/icons/22x22/dtool_logo.png?raw=True
|
|
23
|
+
:height: 20px
|
|
24
|
+
:target: https://github.com/jic-dtool/dtool-http
|
|
25
|
+
.. |pypi| image:: https://img.shields.io/pypi/v/dtool-http
|
|
26
|
+
:target: https://pypi.org/project/dtool-http/
|
|
27
|
+
.. |tag| image:: https://img.shields.io/github/v/tag/jic-dtool/dtool-http
|
|
28
|
+
:target: https://github.com/jic-dtool/dtool-http/tags
|
|
29
|
+
.. |test| image:: https://img.shields.io/github/actions/workflow/status/jic-dtool/dtool-http/test.yml?branch=master&label=tests
|
|
30
|
+
:target: https://github.com/jic-dtool/dtool-http/actions/workflows/test.yml
|
|
31
|
+
.. |coverage| image:: https://codecov.io/github/jic-dtool/dtool-http/coverage.svg?branch=master
|
|
32
|
+
:target: https://codecov.io/github/jic-dtool/dtool-http?branch=master
|
|
33
|
+
|
|
34
|
+
|dtool| |pypi| |tag| |test| |coverage|
|
|
35
|
+
|
|
36
|
+
- GitHub: https://github.com/jic-dtool/dtool-http
|
|
37
|
+
- Free software: MIT License
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
Features
|
|
41
|
+
--------
|
|
42
|
+
|
|
43
|
+
- Publish dtool datasets by making them accessible via HTTP(S)
|
|
44
|
+
- Interact with dtool datasets over HTTP(S)
|
|
45
|
+
- Copy a dataset over HTTP(S)
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
Installation
|
|
49
|
+
------------
|
|
50
|
+
|
|
51
|
+
To install the dtool-http package.
|
|
52
|
+
|
|
53
|
+
.. code-block:: bash
|
|
54
|
+
|
|
55
|
+
cd dtool-http
|
|
56
|
+
python setup.py install
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
Usage
|
|
60
|
+
-----
|
|
61
|
+
|
|
62
|
+
To publish a dataset hosted in Amazon S3 or Microsoft Azure Storage use the
|
|
63
|
+
``dtool_publish_dataset`` command line utility::
|
|
64
|
+
|
|
65
|
+
$ dtool_publish_dataset azure://jicinformatics/c58038a4-3a54-425e-9087-144d0733387f
|
|
66
|
+
Dataset accessible at: https://jicinformatics.blob.core.windows.net/c58038a4-3a54-425e-9087-144d0733387f
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
To show the descriptive metadata of the published dataset::
|
|
70
|
+
|
|
71
|
+
$ dtool readme show https://jicinformatics.blob.core.windows.net/c58038a4-3a54-425e-9087-144d0733387f
|
|
72
|
+
---
|
|
73
|
+
description: Enterobacteria phage lambda, complete genome
|
|
74
|
+
creation_date: 2018-02-06
|
|
75
|
+
accession: NC_001416.1
|
|
76
|
+
link: https://www.ncbi.nlm.nih.gov/nuccore/NC_001416.1
|
|
77
|
+
reference: |
|
|
78
|
+
Nucleotide [Internet]. Bethesda (MD):
|
|
79
|
+
National Library of Medicine (US),
|
|
80
|
+
National Center for Biotechnology Information; [1988] - .
|
|
81
|
+
Accession No. NC_001416.1, Enterobacteria phage lambda, complete genome
|
|
82
|
+
[cited 2018 Feb 06]
|
|
83
|
+
Available from: https://www.ncbi.nlm.nih.gov/nuccore/NC_001416.1
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
To copy the dataset to local disk::
|
|
87
|
+
|
|
88
|
+
$ dtool copy https://jicinformatics.blob.core.windows.net/c58038a4-3a54-425e-9087-144d0733387f ~/my_datasets
|
|
89
|
+
Dataset copied to:
|
|
90
|
+
file:///Users/olssont/my_datasets/lamda-phage-genome
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
Serving a directory of datasets over HTTP
|
|
94
|
+
-----------------------------------------
|
|
95
|
+
|
|
96
|
+
There is a simple utility for serving datasets in a directory over HTTP called
|
|
97
|
+
``dtool_serve_direcotry``. This is mainly useful for testing purposes.
|
|
98
|
+
|
|
99
|
+
Usage::
|
|
100
|
+
|
|
101
|
+
$ dtool_serve_directory ~/my_datasets
|
|
102
|
+
|
|
103
|
+
The default port used is 8081. To show the descriptive metadata in the README
|
|
104
|
+
one can use dtool::
|
|
105
|
+
|
|
106
|
+
$ dtool readme show http://localhost:8081/lamda-phage-genome
|
|
107
|
+
---
|
|
108
|
+
description: Enterobacteria phage lambda, complete genome
|
|
109
|
+
creation_date: 2018-02-06
|
|
110
|
+
accession: NC_001416.1
|
|
111
|
+
link: https://www.ncbi.nlm.nih.gov/nuccore/NC_001416.1
|
|
112
|
+
reference: |
|
|
113
|
+
Nucleotide [Internet]. Bethesda (MD):
|
|
114
|
+
National Library of Medicine (US),
|
|
115
|
+
National Center for Biotechnology Information; [1988] - .
|
|
116
|
+
Accession No. NC_001416.1, Enterobacteria phage lambda, complete genome
|
|
117
|
+
[cited 2018 Feb 06]
|
|
118
|
+
Available from: https://www.ncbi.nlm.nih.gov/nuccore/NC_001416.1
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
Related packages
|
|
122
|
+
----------------
|
|
123
|
+
|
|
124
|
+
- `dtoolcore <https://github.com/jic-dtool/dtoolcore>`_
|
|
125
|
+
- `dtool-cli <https://github.com/jic-dtool/dtool-cli>`_
|
|
126
|
+
- `dtool-info <https://github.com/jic-dtool/dtool-info>`_
|
|
127
|
+
- `dtool-s3 <https://github.com/jic-dtool/dtool-s3>`_
|
|
128
|
+
- `dtool-azure <https://github.com/jic-dtool/dtool-azure>`_
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
dtool_http/__init__.py,sha256=9eQqYLqumZZSzL3DMyTH1GIzXPd5CcGHJkHURahOLJE,355
|
|
2
|
+
dtool_http/publish.py,sha256=MKoBPzjhCUD1meMdKcnz0xes6SQ3SD_kzQi_0qr2wxs,1334
|
|
3
|
+
dtool_http/server.py,sha256=8ZmDKuvEBVnGscftUqs9c62qQI6JLgFHMy385Y_jeYQ,4373
|
|
4
|
+
dtool_http/storagebroker.py,sha256=dWj9T7G5CL_jNk5yPai3XVFz1htJHE1gO8brVUiFJqE,5623
|
|
5
|
+
dtool_http/version.py,sha256=066-gEgl89JZttvQIeF8xCmsrdAhgid_eoH5BBz7G58,511
|
|
6
|
+
dtool_http-0.5.2.dist-info/licenses/LICENSE.rst,sha256=UedyOiE3-MK9IJc1Fuh-THjZGhIR9FWkB2t0Ki7-P1U,1083
|
|
7
|
+
dtool_http-0.5.2.dist-info/METADATA,sha256=xdwV2D2B8v96rVetWW8AYzfCvYc-cw69EQa6rRve0bk,4587
|
|
8
|
+
dtool_http-0.5.2.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
|
|
9
|
+
dtool_http-0.5.2.dist-info/entry_points.txt,sha256=Zcmp9UxLNxW8S4wIknUs8jlO16JOT-lrfeXJ4plNKqI,258
|
|
10
|
+
dtool_http-0.5.2.dist-info/top_level.txt,sha256=T8QmLrwPmj76NpX4fYqUZSVOhUC46YsMl2v1Y-KeAc8,11
|
|
11
|
+
dtool_http-0.5.2.dist-info/RECORD,,
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
[dtool.cli]
|
|
2
|
+
dtool_publish_dataset = dtool_http.publish:cli
|
|
3
|
+
dtool_serve_directory = dtool_http.server:cli
|
|
4
|
+
|
|
5
|
+
[dtool.storage_brokers]
|
|
6
|
+
HTTPSStorageBroker = dtool_http.storagebroker:HTTPSStorageBroker
|
|
7
|
+
HTTPStorageBroker = dtool_http.storagebroker:HTTPStorageBroker
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
===========
|
|
3
|
+
|
|
4
|
+
Copyright (c) 2018 Tjelvar Olsson
|
|
5
|
+
|
|
6
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
in the Software without restriction, including without limitation the rights
|
|
9
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
furnished to do so, subject to the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
SOFTWARE.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
dtool_http
|