A Python CLI tool for uploading files from URLs directly to cloud storage. Currently supports Google Cloud Storage (GCP) with a modular architecture designed for easy extension to other cloud providers.
- π Upload files directly from URLs to cloud storage
- βοΈ Google Cloud Storage support
- π¦ Streaming uploads with progress tracking
- βοΈ Configurable settings and logging
- π§ Extensible architecture for additional cloud providers
- π‘οΈ Async/await for efficient stream processing
- Python 3.11 or higher
- Google Cloud Storage credentials (for GCP uploads)
pip install theloopgit clone https://github.com/matterai/theloop.git
cd theloop
pip install -e .git clone https://github.com/matterai/theloop.git
cd theloop
uv pip install -e .
uv pip install pytest pytest-cov pytest-asyncioUpload a file from a URL to Google Cloud Storage:
theloop upload "https://example.com/file.pdf" "my-bucket" "uploads/file.pdf"theloop upload \
"https://example.com/file.pdf" \
"my-bucket" \
"uploads/file.pdf" \
--credentials ~/path/to/service-account.json \
--project my-gcp-project-idtheloop upload \
"https://example.com/file.pdf" \
"my-bucket" \
"uploads/file.pdf" \
--provider gcpView current settings:
theloop settingsSettings are stored in ~/.theloop/settings.json and include:
- Logging configuration
- Chunk size for uploads
- Default cloud provider settings
-
Application Default Credentials (recommended for local development):
gcloud auth application-default login
-
Service Account Key:
theloop upload <url> <bucket> <path> --credentials /path/to/service-account.json
-
Environment Variable:
export GOOGLE_APPLICATION_CREDENTIALS="/path/to/service-account.json" theloop upload <url> <bucket> <path>
src/theloop/
βββ __init__.py
βββ cli.py # CLI interface using Typer
βββ interfaces.py # Protocol definitions
βββ services/
βββ config_manager.py # Settings management
βββ gcp_uploader.py # GCP-specific upload logic
βββ logging_configurator.py
-
Clone the repository:
git clone https://github.com/matterai/theloop.git cd theloop -
Install dependencies:
uv pip install -e . uv pip install pytest pytest-cov pytest-asyncio -
Run tests:
pytest
-
Run from source:
uv run python -m src.main upload <url> <bucket> <path>
The project uses pytest for testing with support for async code:
# Run all tests
pytest
# Run with coverage
pytest --cov=theloop
# Run specific test file
pytest tests/test_uploader.pyExample test structure:
import pytest
@pytest.mark.asyncio
async def test_async_upload():
# Test async upload functionality
pass-
Create uploader class in
services/:from theloop.interfaces import Uploader class NewProviderUploader(Uploader): async def upload_stream_async(self, url: str, bucket: str, path: str) -> None: # Implement upload logic pass
-
Update CLI in
cli.py:def _get_uploader(provider: str, settings: Settings, ...) -> Uploader: if provider == "new-provider": return NewProviderUploader(...) # ... existing providers
- Follow PEP 8 for Python code style
- Use type hints throughout the codebase
- Implement proper error handling with user-friendly messages
- Use async/await for I/O operations
- Follow the existing patterns for configuration and logging
We welcome contributions! Please follow these steps:
- Fork the repository
- Create a feature branch:
git checkout -b feature/your-feature-name
- Make your changes following the development guidelines
- Add tests for new functionality
- Run tests to ensure everything works:
pytest
- Commit your changes:
git commit -m "Add your feature description" - Push to your fork:
git push origin feature/your-feature-name
- Create a Pull Request
- Ensure all tests pass
- Add tests for new features
- Update documentation as needed
- Follow existing code style and patterns
- Write clear commit messages
- Keep pull requests focused and small
This project is licensed under the MIT License - see the LICENSE section below for details.
- Issues: GitHub Issues
- Discussions: GitHub Discussions
- AWS S3 support
- Azure Blob Storage support
- Configuration file support
- Batch upload functionality
- Resume interrupted uploads
MIT License
Copyright (c) 2024 Vladimir Vlasiuk
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.