Skip to main content

No project description provided

Project description

Client for CTA Data dCache storage access

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.

Accessing dCache with tokens

The latest version of ctadata implements direct download/upload mode without using downloadservice as proxy.

Installation

Currently the direct API uses oidc-agent tool for the token maintanance and davix tools for downloading and uploading the files. These tools can be either compiled locally and added to PATH environment variable or installed inside [micromamba] (https://mamba.readthedocs.io/en/latest/user_guide/micromamba.html) or [conda] (https://anaconda.org/anaconda/conda) environment. Below is the example of the installation using micromamba package manager.

$ micromamba create -n ctadata python oidc-agent davix  # create micromamba environment with python and required binaries
$ micromamba activate ctadata # activate the environment
$ pip install ctadata # install ctadata library in the same environment

Token maintanance

To get access to CTA-CSCS storage you need to generate OpenID Connect token. The token is temporary and needs to be updated on regular bases. This process is implemented by the token agent service which can be started by the command

$ cta-data start-agent

The token is being stored in the user's home directory, so the above command needs to be started only on a single machine. During the agent initialization process an account is created for the token maintanance. The user is being asked to authenticate the account creation by visiting the authentication page in a browser on any device.

Basic usage

As soon as the account creation process completes the token is created and one can start using other direct API functions.

Listing directory contents

import ctadata

for path in ctadata.list_dir("cta"):
    print(path)

Downloading files and directories

To download contents of some file or dir:

import ctadata

# downloading single file
ctadata.fetch_and_save_file_or_dir("lst/some-data-dir/some-data-file") 

# recursively downloading a directory
ctadata.fetch_and_save_file_or_dir("lst/some-data-dir", recursive=True)

or, in bash:

cta-data get lst/some-data-dir/some-data-file
cta-data get --recursive lst/some-data-dir

Uploading files and directories

To upload a file:

import ctadata
ctadata.upload_file("latest.txt", "your-folder/new-file-name.md")
ctadata.upload_file("latest.txt", "your-folder/") # will autocomplete to `your-folder/latest.txt`

You can also use command line interface to do this:

$ cta-data put latest-file-list latest-file-list-bla-bla

Using token in external tools

You can print the token to use it with external tools with the following command

$ cta-data print-token

Using dev instance of dCache server

To access dev instance one may use -d or --dev option in command interface:

$ cta-data -d list /

In python API one should use dev_instance optional parameter:

import ctadata

for path in ctadata.list_dir("/", dev_instance=True):
    print(path)

Note that in order to access dev instance server you will have to maintain separate token using agent service, which can be started with command:

$ cta-data -d start-agent

Usage from within CTA CSCS JupyterHub platform

The ctadata library can be used within the CTA CSCS JupyterHub platform, as described above, without any changes or limitations.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ctadata-0.7.0.tar.gz (6.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ctadata-0.7.0-py3-none-any.whl (8.2 kB view details)

Uploaded Python 3

File details

Details for the file ctadata-0.7.0.tar.gz.

File metadata

  • Download URL: ctadata-0.7.0.tar.gz
  • Upload date:
  • Size: 6.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.1 CPython/3.11.10 Linux/6.8.0-52-generic

File hashes

Hashes for ctadata-0.7.0.tar.gz
Algorithm Hash digest
SHA256 1a6c815562755fb693361c1c0fe90dbfbe777ceba248202bd2ded68eff226ac5
MD5 0d1a774ac3559a704dd690af166fc4a2
BLAKE2b-256 646ae72930f9463c317044be5428cfa16e8ddedcc4f1ef23d2fc3734619ce9d0

See more details on using hashes here.

File details

Details for the file ctadata-0.7.0-py3-none-any.whl.

File metadata

  • Download URL: ctadata-0.7.0-py3-none-any.whl
  • Upload date:
  • Size: 8.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.1 CPython/3.11.10 Linux/6.8.0-52-generic

File hashes

Hashes for ctadata-0.7.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d4b4cb22ec2f63665eba2d5d642f1280b98c012a4f03811350493f49f1752fa4
MD5 9508c69e9feedac2632662f52e9f1df3
BLAKE2b-256 7e2f2f00730e544682f72c8fc12c85fa0ab428d75ba1440d9216f105bedd703c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page