Skip to main content

CTP

Collect Then Process: A python data collection library

What do you need to do if you are running some programs on the remote server and you want to collect some runtime data during program running, and process it on your local PC, e.g. plot a figure? See how many steps you need without ctp:

  • collect the data
  • serialize the data
  • download the data to your local computer through various ways: scp, ftp ...
  • deserialize the data on your local computer
  • process the data, e.g plot a figure

Tired of all this? ctp now provides a easy to use solution of just Collect then Process:

Collect on the remote cloud server:

import ctp
with ctp.append_run("my_experiment") as run:
    run.collect("my_data", data)

Then Process on your local computer:

import ctp
with ctp.get_run("my_experiment") as run:
    data = run.process("my_data")

Usage:

pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple cthenp

Server:

To start a server locally:

import ctp
ctp.start_listen(ip = "localhost", port=50057)

Collect:

Example usage of collecting data and transfer it to server:

import ctp
run = ctp.append_run("sample_exp")

This appends a new run of the experiment, to collect data to new run:

for i in range(10):
    run.collect("sample_data")

Or you can also pass a list created by yourself by:

sample_data = [] # sample data list created by your self
run.monitor("sample_data", sample_data)
for i in range(10):
    sample_data.append(i)

After collecting data, finish collect and upload all data to server:

run.stop_collect()

If you don't want to deal with start and stop by your self, you can:

with ctp.append_run("sample_exp") as run:
    ... ## your code here

will automatically upload all data once this block is finished

Process

To process data from other machines:

import ctp
run = ctp.get_run("sample_exp")

get sample data:

sample_data = run.process("sample_data")

API

ctp

def start_listen(ip : str = "localhost", port : int = 50057) -> None:

def append_run(exp_name : str, ip : str = "localhost", port : int = 50057) -> ctp.Run:


def get_run(exp_name : str, ip : str = "localhost", port : int = 50057) -> ctp.Run:

ctp.Run:

def collect(self, user_label : str, data : any = None, prefix : str = '_') -> List[any]:

def monitor(self, user_label : str, datas : List[any], prefix : str = '_') -> None:

def stop_collect() -> None:

def process(self, user_label : str = None) -> Optional[dict[str,List[any]],List[any]]:

Metadata

Release files for cthenp 0.2.0

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

Source distribution (sdist)

Source distribution for cthenp 0.2.0
File Size Uploaded
cthenp-0.2.0.tar.gz 15.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for cthenp 0.2.0
File Interpreter ABI Platform
cthenp-0.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 30.5 kB

Release files / cthenp-0.2.0.tar.gz

Download URL cthenp-0.2.0.tar.gz
Size 15.7 kB
Tags Source
SHA-256 checksum
How to use checksums
8c92ce702b3b7b4c2d736bf8f056aff507cb1d1fe511485dfac3703bb2a2c47c
BLAKE2b-256 checksum
How to use checksums
dbd93adf1f81841093faf0a4abef5c3a1ea3ee883b0df0ba544a3b1e927651bd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.18

Release files / cthenp-0.2.0-py3-none-any.whl

Download URL cthenp-0.2.0-py3-none-any.whl
Size 14.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7e13661b0261b848f7c335576f6fef6c22b2543a7df79bf012fc854958802297
BLAKE2b-256 checksum
How to use checksums
94e183100bd54452a0b1e7f031d44089c0975004d3651eb3e96d0feef43e5992
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.18

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files

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