Skip to content

Commit b5a6a2c

Browse files
authored
Merge pull request #8 from DACCS-Climate/readme
Adding README
2 parents 76214b0 + a78f6f3 commit b5a6a2c

File tree

1 file changed

+108
-2
lines changed

1 file changed

+108
-2
lines changed

README.md

Lines changed: 108 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,108 @@
1-
# DACCS python client
2-
A python library to access DACCS network information.
1+
# Marble python client
2+
A python library to access information about the Marble climate infomatics network. The library provides a pythonic interface to the Marble network's [central registry](https://github.com/DACCS-Climate/Marble-node-registry). Users of the network are encouraged to use this library to access the network information and avoid hardcoding URLs to various nodes or services.
3+
4+
## Installation
5+
6+
To install `marble_client` issue this command:
7+
```shell
8+
pip install marble_client
9+
```
10+
11+
## Basic usage
12+
13+
The first thing to do is to get a `client` object:
14+
15+
```python
16+
>>> from marble_client import MarbleClient
17+
18+
>>> client = MarbleClient()
19+
```
20+
21+
All the information about the network can now be retrieved from the `client` object. E.g. the nodes available in the network can be accessed as:
22+
```python
23+
>>> client.nodes
24+
{'UofT': <marble_client.node.MarbleNode at 0x10c129990>,
25+
'PAVICS': <marble_client.node.MarbleNode at 0x10c6dd690>,
26+
'Hirondelle': <marble_client.node.MarbleNode at 0x10c6dd890>}
27+
```
28+
The returned object is a python `dict` with node names for keys and `MarbleNode` objects as values. A particular node can be accessed as:
29+
30+
```python
31+
>>> mynode = client['UofT']
32+
>>> type(mynode)
33+
marble_client.node.MarbleNode
34+
```
35+
36+
Now that one has a Marble node of interest, a useful operation would be to check if that node is online in realtime, this can be done as:
37+
38+
```python
39+
>>> mynode.is_online()
40+
True
41+
```
42+
43+
The URL for the node can be retrieved as:
44+
```python
45+
>>> mynode.url
46+
'https://daccs.cs.toronto.edu'
47+
```
48+
49+
Various other qualities about the node can be accessed as shown below (see [implementation](https://github.com/DACCS-Climate/marble_client_python/blob/main/marble_client/node.py) for the full list of available attributes).
50+
51+
```python
52+
>>> mynode.affiliation
53+
'University of Toronto'
54+
>>> mynode.contact
55+
56+
>>> mynode.marble_version # The version of the software stack available on this node
57+
'1.27.0'
58+
>>> mynode.location
59+
{'longitude': -79.39, 'latitude': 43.65}
60+
```
61+
62+
The "services" that a Marble node offers can differ from one node to another. A list of which services are offered at a given node can be inquired as follows:
63+
```python
64+
>>> mynode.services
65+
['geoserver',
66+
'flyingpigeon',
67+
'finch',
68+
'raven',
69+
'hummingbird',
70+
'thredds',
71+
'jupyterhub',
72+
'weaver']
73+
```
74+
75+
To get further information on one of the services, first retrieve that service. This can be done in one of two ways:
76+
```python
77+
>>> service = mynode['thredds']
78+
>>> type(service)
79+
marble_client.services.MarbleService
80+
>>>
81+
>>> service = mynode.thredds
82+
>>> type(service)
83+
marble_client.services.MarbleService
84+
```
85+
86+
The most important thing one needs from the service is the endpoint at which the service is located:
87+
```python
88+
>>> service.url
89+
'https://daccs.cs.toronto.edu/thredds/'
90+
```
91+
92+
The service URL can also be accessed directly using the service object's name:
93+
```python
94+
>>> service
95+
'https://daccs.cs.toronto.edu/thredds/'
96+
```
97+
98+
Various attributes that can be accessed on the `MarbleService` object can be found by consulting the [implementation](https://github.com/DACCS-Climate/marble_client_python/blob/main/marble_client/services.py).
99+
100+
Of course, all operations can be chained, so if you don't need `MarbleClient`, `MarbleNode` or `MarbleService` objects for future operations, then to get, for example, the weaver service endpoint for the "PAVICS" node, one can do:
101+
```python
102+
>>> url = MarbleClient()["PAVICS"].weaver.url # returns a string object
103+
>>> print(f"Weaver URL is {url}")
104+
Weaver URL is https://pavics.ouranos.ca/weaver/
105+
>>> # A MarbleService object is returned that can be used wherever a string can be used
106+
>>> print(f"Weaver URL is {MarbleClient()['PAVICS'].weaver}")
107+
Weaver URL is https://pavics.ouranos.ca/weaver/
108+
```

0 commit comments

Comments
 (0)