Skip to content

Commit 55fadb3

Browse files
committed
Adding README
1 parent 76214b0 commit 55fadb3

File tree

1 file changed

+101
-2
lines changed

1 file changed

+101
-2
lines changed

README.md

Lines changed: 101 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,101 @@
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+
## Basic usage
5+
6+
The first thing to do is to get a `client` object:
7+
8+
```python
9+
>>> from marble_client import MarbleClient
10+
11+
>>> client = MarbleClient()
12+
```
13+
14+
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:
15+
```python
16+
>>> client.nodes
17+
{'UofT': <marble_client.node.MarbleNode at 0x10c129990>,
18+
'PAVICS': <marble_client.node.MarbleNode at 0x10c6dd690>,
19+
'Hirondelle': <marble_client.node.MarbleNode at 0x10c6dd890>}
20+
```
21+
The returned object is a python `dict` with node names for keys and `MarbleNode` objects as values. A particular node can be accessed as:
22+
23+
```python
24+
>>> mynode = client['UofT']
25+
>>> type(mynode)
26+
marble_client.node.MarbleNode
27+
```
28+
29+
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:
30+
31+
```python
32+
>>> mynode.is_online()
33+
True
34+
```
35+
36+
The URL for the node can be retrieved as:
37+
```python
38+
>>> mynode.url
39+
'https://daccs.cs.toronto.edu'
40+
```
41+
42+
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).
43+
44+
```python
45+
>>> mynode.affiliation
46+
'University of Toronto'
47+
>>> mynode.contact
48+
49+
>>> mynode.marble_version # The version of the software stack available on this node
50+
'1.27.0'
51+
>>> mynode.location
52+
{'longitude': -79.39, 'latitude': 43.65}
53+
```
54+
55+
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:
56+
```python
57+
>>> mynode.services
58+
['geoserver',
59+
'flyingpigeon',
60+
'finch',
61+
'raven',
62+
'hummingbird',
63+
'thredds',
64+
'jupyterhub',
65+
'weaver']
66+
```
67+
68+
To get further information on one of the services, first retrieve that service. This can be done in one of two ways:
69+
```python
70+
>>> service = mynode['thredds']
71+
>>> type(service)
72+
marble_client.services.MarbleService
73+
>>>
74+
>>> service = mynode.thredds
75+
>>> type(service)
76+
marble_client.services.MarbleService
77+
```
78+
79+
The most important thing one needs from the service is the endpoint at which the service is located:
80+
```python
81+
>>> service.url
82+
'https://daccs.cs.toronto.edu/thredds/'
83+
```
84+
85+
The service URL can also be accessed directly using the service object's name:
86+
```python
87+
>>> service
88+
'https://daccs.cs.toronto.edu/thredds/'
89+
```
90+
91+
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).
92+
93+
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:
94+
```python
95+
>>> url = MarbleClient()["PAVICS"].weaver.url # returns a string object
96+
>>> print(f"Weaver URL is {url}")
97+
Weaver URL is https://pavics.ouranos.ca/weaver/
98+
>>> # A MarbleService object is returned that can be used wherever a string can be used
99+
>>> print(f"Weaver URL is {MarbleClient()['PAVICS'].weaver}")
100+
Weaver URL is https://pavics.ouranos.ca/weaver/
101+
```

0 commit comments

Comments
 (0)