Skip to main content

GitHub Actions Status Coveralls Status License GitHub Releases PyPI Version GitHub Issues

hepdata-converter-ws-client

Light client wrapper for interaction with hepdata-converter-ws (Web Services). It is recommended to use this wrapper instead of manually creating requests to hepdata-converter-ws.

The reason for creating this package is the fact that the hepdata-converter-ws API requires compressing files into tar.gz format and encoding using Base64 in order to pass them as an argument in the JSON request. Doing this manually every time someone wants to call the hepdata-converter-ws API was a little cumbersome: that's why this light wrapper was born.

Additionally, the library provides additional functionality when it comes to writing the output of the convert function: instead of receiving raw tar.gz content it is possible to extract to a specified file path.

Sample usage

The library exposes one single function hepdata_converter_ws_client.convert which is very similar to hepdata_converter.convert. It accepts the additional argument url, and restricts input / output to str, unicode and file objects (objects supporting read, write, seek, tell).

The options parameter should be the same as with the hepdata_converter library.

The timeout parameter can be used to set a timeout for requests (defaults to 600s).

The library defines the exception hepdata_converter_ws_client.Error which will be thrown on timeouts or other errors connecting to the server.

A function hepdata_converter_ws_client.get_data_size gets the size in bytes of the JSON data that would be sent to the converter. This could be useful in checking that a maximum payload size imposed by a web server is not exceeded.

Function description

hepdata_converter_ws_client.convert function has proper docstring describing its arguments and return values. Similarly for hepdata_converter_ws_client.get_data_size with corresponding docstring.

Convert using file paths

Arguments passed as input and output can be file paths or file objects. Below is an example of how to utilise the convert function with file paths.

import hepdata_converter_ws_client

# using path to input file, and writing output directly to output_path
input_path = '/path/to/input.txt'
output_path = '/path/to/output/dir'
hepdata_converter_ws_client.convert('http://hepdata-converter-ws-addr:port', input_path, output_path,
                                    options={'input_format': 'oldhepdata'})

Convert using input path and output file object

Input can always be a file object (as long as the input Parser supports single files). Output can be a file object only if the keyword argument extract=False. In this case the binary content of the returned tar.gz file will be written to the output file object. It is then the responsibility of the user to decompress it.

import hepdata_converter_ws_client
from io import BytesIO
# using path to input file, writing to output stream
input_path = '/path/to/input.txt'
output = BytesIO()
hepdata_converter_ws_client.convert('http://hepdata-converter-ws-addr:port', input_path, output,
                                    options={'input_format': 'oldhepdata'}, extract=False)

Metadata

Release files for hepdata-converter-ws-client 0.2.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for hepdata-converter-ws-client 0.2.2
File Size Uploaded
hepdata-converter-ws-client-0.2.2.tar.gz 5.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for hepdata-converter-ws-client 0.2.2
File Interpreter ABI Platform
hepdata_converter_ws_client-0.2.2-py2.py3-none-any.whl Python 2, Python 3 none any Details

Total release size: 18.5 kB

Release files / hepdata-converter-ws-client-0.2.2.tar.gz

Download URL hepdata-converter-ws-client-0.2.2.tar.gz
Size 5.5 kB
Tags Source
SHA-256 checksum
How to use checksums
b21adc6a0f4dbd0c0ffa678bb8be2c9bcf70bbc70f9709dd8034c76a29ab9f58
BLAKE2b-256 checksum
How to use checksums
e2202011e4f9f810ca9f827840dd4303f67087db2dcee5de4b1f549e0ac6f398
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/53.0.0 requests-toolbelt/0.9.1 tqdm/4.58.0 CPython/3.9.2

Release files / hepdata_converter_ws_client-0.2.2-py2.py3-none-any.whl

Download URL hepdata_converter_ws_client-0.2.2-py2.py3-none-any.whl
Size 13.0 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
7babae8a08d040dca340302ff35b62ec17cac8153436c685cbdf19a762578e09
BLAKE2b-256 checksum
How to use checksums
117da9832399faa67131e9e42ba7bc89f719495d3cf0ef3ff27e7c19b1963570
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/53.0.0 requests-toolbelt/0.9.1 tqdm/4.58.0 CPython/3.9.2

Release history Release notifications | RSS feed

This release

0.2.2 This release

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.6

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

1 release file

0.1.2

1 release file

0.1.1

1 release file

0.1.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page