1import numpy as np
2from ._memobin import (
3 construct_reconstructed_url,
4 exists_in_memobin,
5 upload_to_memobin,
6)
9def upload_reconstructed_to_memobin(
10 data: np.ndarray,
11 algorithm_name: str,
12 dataset_name: str,
13 algorithm_version: str,
14 dataset_version: str,
15 system_version: str,
16 memobin_api_key: str,
17 verbose: bool = True,
18) -> None:
19 """Upload reconstructed array to memobin as raw .dat format.
21 Args:
22 data: The reconstructed numpy array to upload
23 algorithm_name: Name of the algorithm
24 dataset_name: Name of the dataset
25 algorithm_version: Version of the algorithm
26 dataset_version: Version of the dataset
27 system_version: Version of the system
28 memobin_api_key: API key for memobin
29 verbose: Whether to print progress messages
30 """
31 try:
32 # Upload raw .dat format
33 reconstructed_url_raw = construct_reconstructed_url(
34 algorithm_name, dataset_name, algorithm_version, dataset_version, system_version, "dat"
35 )
36 if not exists_in_memobin(reconstructed_url_raw):
37 if verbose:
38 print(" Uploading reconstructed array to memobin...")
39 upload_to_memobin(
40 data.tobytes(),
41 reconstructed_url_raw,
42 memobin_api_key,
43 content_type="application/octet-stream",
44 )
45 if verbose:
46 print(" Successfully uploaded reconstructed data")
47 except Exception as e:
48 print(f" Warning: Failed to upload reconstructed data to memobin: {str(e)}")