No project description provided
Project description
Client for CTA Data Download Service at Swiss CTA DC
Disclaimer
This is a prototype development only for Swiss CTA DC. Please report bugs here, and for any details please inquire the CTAO CH DC management.
Purpose
CTA data are/will be stored at CTAO-CH data center at CSCS. These data should be accessible for selected external users. In addition, these files should be available within interactive analysis platform at CSCS. This client presents an API access to these services and data.
Installation
$ pip install 'ctadata>=0.2.6'
Usage from within CTA CSCS JupyterHub platform
From within CTA CSCS JupyterHub platform, selected authorized users are able to access the "data download service", like so:
import ctadata
for url in ctadata.list_dir("cta/DL1/20241114/v0.1/"):
if 'datacheck' not in url and '.0100' in url and '11111' in url:
print("stored", ctadata.fetch_and_save_file(url)/1024/1024, "Mb")
print("found keys", h5py.File(url.split("/")[-1]).keys())
To download a file:
ctadata.fetch_and_save_file_or_dir("lst/some-data-dir", recursive=True)
or, in bash and recursively:
ctadata get --recursive lst/some-data-dir
Uploading files
To upload a file:
ctadata.upload_file("latest", "filelists/latest-file-list")
The result is:
{
"path": "lst/users/volodymyr_savchenko_epfl_ch/filelists/latest-file-list",
"status": "uploaded",
"total_written": 60098730
}
Note that for every user, the file is uploaded to their own directory constructed from the user name. The path specified is relative to this directory. If you need to move the files to common directories, please as support. But you likely want to just share returned path to be used as so:
ctadata.fetch_and_save_file("lst/users/volodymyr_savchenko_epfl_ch/filelists/latest-file-list")
You can also use command line interface to do this:
$ cta-data put latest-file-list latest-file-list-bla-bla
Beware that all the files written are accessible to all CTAO members and all platform users.
From outside (possibly another jupyterhub)
You need to get yourself a jupyterhub token, it will be used to authenticate to the download service.
If you are in the session, navigate to the hub control panel this way:
Request a token:
The rest is similar to the previous case:
import os
os.environ["CTADS_URL"] = "DATA-DISTRIBUTING-JUPYTERHUB/services/downloadservice/"
os.environ["JUPYTERHUB_API_TOKEN"] = "INSERT-YOUR-TOKEN-HERE"
for url in ctadata.list_dir("cta/DL1/20241114/v0.1"):
if 'datacheck' not in url and '.0100' in url and '11111' in url:
print("stored", ctadata.fetch_and_save_file(url)/1024/1024, "Mb")
print("found keys", h5py.File(url.split("/")[-1]).keys())
Webdav Client
In order to make use of bare WebDAV interface of the storage, ctadata
also provides a configured webdav4
client (see webdav4 for documentation).
client = ctadata.webdav4_client()
client.ls("/")
client.uploadFile("example.txt", "remote/example.txt")
Please see WebDAV4 documenation for details on it's wide range of features.
Delegating a proxy grid certificate to the Platform
In order to make use of your own grid certificate to access CTA-CSCS storage from within CTA interactive platform it is necessary to upload you short-term proxy certificate to the platform. cta-data
provides an easy way to do this:
This tools also offers a way to upload your own time limited certificate to access the background webdav server.
import ctadata
ctadata.upload_certificate('yourcertificate.crt')
Note that if you do not upload your own certificate, you can ask to make use of a shared robot certificate used for data syncing.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file ctadata-0.3.0.tar.gz
.
File metadata
- Download URL: ctadata-0.3.0.tar.gz
- Upload date:
- Size: 5.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.4.0 CPython/3.9.16 Linux/5.15.0-76-generic
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c58d22b0fffcdc2695c9d8ae9686a32343e98477884106d344083eb1da0586d9 |
|
MD5 | 2d79c8caac158e47a475e1bcbe54b0df |
|
BLAKE2b-256 | dd3047ab8fbee284c63e516da378b021bc79ad2d6129fb664085ab74e4dd8936 |
File details
Details for the file ctadata-0.3.0-py3-none-any.whl
.
File metadata
- Download URL: ctadata-0.3.0-py3-none-any.whl
- Upload date:
- Size: 6.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.4.0 CPython/3.9.16 Linux/5.15.0-76-generic
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5a2fa39ab94d7b2a360ebcc730bd5a0108c58a5212fed062d9a828ec01b39015 |
|
MD5 | 16a5186119d27f869263269a0b18876b |
|
BLAKE2b-256 | 06ab337e4f47bd128c893e94534176ff625a451add20b1379cfeaea51edfe7b1 |