Skip to main content

CLI utility for uploading data to CUE (Cloud Upload Environment)

Project description

CUE Provider Utility (cue-upload)

Version: 0.1.0
License: Apache-2.0

Overview

The CUE Provider Utility (cue-upload) is a Python-based command-line interface (CLI) designed to facilitate the upload of files and entire folder structures to the CUE (Cloud Upload Environment) backend system. It is optimized for large files, provides a rich user experience, and ensures data integrity through robust error handling and checksum validation.

This tool is intended for users who need to transfer data to the CUE system from their local machines.

Features

  • Upload individual files or entire directories recursively.
  • Automatic handling of single-part vs. multipart uploads based on file size.
  • Concurrent uploads for multiple files within a folder and for parts of a single large file.
  • SHA256 checksum validation for data integrity.
  • User-friendly configuration via a config.toml file and interactive configure command.
  • Flexible authentication token management (CLI option, config file, environment variable, .netrc).
  • Support for different backend environments (prod, uat, sit, local).
  • Management of ignored file patterns (system defaults + user-defined).
  • Detailed logging to both console (with colors and progress bars via Rich) and a log file.
  • Cross-platform compatibility (Windows, macOS, Linux).

Prerequisites

  • Python: Version 3.10 or newer.
  • Poetry: Version 1.2+ is recommended for dependency management. Installation instructions can be found at python-poetry.org.

Installation

Clone the Repository:

git clone https://github.com/ghrcdaac/CUE-Provider-Utility.git
cd CUE-Provider-Utility

Install Dependencies using Poetry:
This command creates a virtual environment and installs all necessary packages.

poetry install

Configuration

The utility is configured via a file located at ~/.cue-upload/config.toml. This file is created automatically the first time you run the tool.

First-Time Setup

The recommended way to set up the CLI is to use the interactive configure command. This will guide you through setting up your API key storage.

cue-upload configure

This will guide you through each option, showing the current value and prompting for a new one. At the end, it will guide you through the API key setup.

Quickly Updating Your API Key

If you only need to update, change, or remove your stored API key without going through all the other settings, you can use the --key flag. This provides a fast and secure way to manage your credentials.

cue-upload configure --key

The prompt will detect if you already have a key stored and ask if you want to overwrite or delete it.

API Key Management

The CLI retrieves your API key from the following sources, in this order of priority:

  1. Command-Line Argument: The -t or --token option. (e.g., cue-upload --token YOUR_KEY ...)
  2. Environment Variable: The CUE_UPLOAD_API_TOKEN environment variable.
  3. .netrc File: A secure, permissions-controlled file in your home directory.
  4. config.toml File: The application's configuration file.

The CLI will print which source it is using when you start an upload.

Basic Usage

Activate the Virtual Environment

Before running any commands, activate the Poetry virtual environment:

poetry shell

General Help

cue-upload -h
cue-upload upload -h

Uploading Files or Folders

# Upload a single file
cue-upload upload -P /path/to/your/file.txt -c your_collection_name

# Upload a folder and specify a target sub-path in the collection
cue-upload upload -P /path/to/your/folder/ -c your_collection_name -tp remote/sub_path/

Managing Configuration

# Run the interactive configuration wizard
cue-upload configure

Viewing Logs

# View the entire log file
cue-upload logs

# View the last 100 lines
cue-upload logs -n 100

Managing Ignored File Patterns

# List all current ignore patterns
cue-upload ignore list

# Add a pattern to ignore all .log files
cue-upload ignore add "*.log"

# Remove a pattern
cue-upload ignore remove "*.log"

# Clear all user-defined patterns
cue-upload ignore reset

Global Options

  • -t, --token YOUR_TOKEN: Provide API key directly.
  • --env ENV_NAME: Target a specific backend environment (prod, uat, sit, local).
  • -v / -vv: Increase console verbosity. -vv includes full network logs.
  • -q: Quiet mode, showing only critical errors.
  • --config /path/to/config.toml: Use a custom configuration file.

Development

Running Tests

Tests are located in the tests/ directory and can be run with pytest.

# Run all tests
pytest

# Run tests with coverage report
pytest --cov=cue_provider_utility tests/

Linters and Formatters

This project uses black, isort, flake8, and mypy to maintain code quality.

black cue_provider_utility/ tests/
isort cue_provider_utility/ tests/
flake8 cue_provider_utility/ tests/
mypy cue_provider_utility/

License

This project is licensed under the Apache License, Version 2.0. See the LICENSE file for details.

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

cue_provider_utility-1.1.0.tar.gz (32.5 kB view details)

Uploaded Source

Built Distribution

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

cue_provider_utility-1.1.0-py3-none-any.whl (38.9 kB view details)

Uploaded Python 3

File details

Details for the file cue_provider_utility-1.1.0.tar.gz.

File metadata

  • Download URL: cue_provider_utility-1.1.0.tar.gz
  • Upload date:
  • Size: 32.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.2 CPython/3.10.12 Linux/6.6.87.2-microsoft-standard-WSL2

File hashes

Hashes for cue_provider_utility-1.1.0.tar.gz
Algorithm Hash digest
SHA256 6cbbf893a0abd74fce2b7d127225c7572dbb184c60b55d7b607994a2de5887c2
MD5 fc4c88845f79ce330cb85e41667d504c
BLAKE2b-256 8eb4cd2572b6334ccc3c09b676c4a32dfc40ef093f8c339a0a1cc30c2eb38f95

See more details on using hashes here.

File details

Details for the file cue_provider_utility-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: cue_provider_utility-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 38.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.2 CPython/3.10.12 Linux/6.6.87.2-microsoft-standard-WSL2

File hashes

Hashes for cue_provider_utility-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a6532088182538d7de50b19994fff0702f1729739c742461864ceed447b26f20
MD5 c41af53406ab9365632e4f44163bc26a
BLAKE2b-256 2f65313a40ac58d693b5329e5503278f3555c011cf21bfaf74279bd85755c646

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