or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

cli-interface.mdindex.mdproject-management.mdpython-api.mdutilities.md
tile.json

tessl/pypi-osfclient

A Python library and command-line interface for interacting with the Open Science Framework

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
pypipkg:pypi/osfclient@0.0.x

To install, run

npx @tessl/cli install tessl/pypi-osfclient@0.0.0

index.mddocs/

OSFClient

A Python library and command-line interface for interacting with the Open Science Framework (OSF). OSFClient enables researchers and developers to programmatically upload, download, and manage large datasets and research files through both Python APIs and CLI commands, supporting scientific workflows and collaborative research projects.

Package Information

  • Package Name: osfclient
  • Language: Python
  • Installation: pip install osfclient
  • License: BSD-3-Clause

Core Imports

from osfclient import OSF

For version information:

from osfclient import __version__

Basic Usage

from osfclient import OSF

# Initialize with authentication
osf = OSF(username='your_username', password='your_password')
# Or use token authentication
osf = OSF(token='your_personal_access_token')

# Get a project
project = osf.project('project_id')
print(f"Project: {project.title}")

# Access default storage
storage = project.storage()

# List all files
for file in storage.files:
    print(f"File: {file.path}, Size: {file.size}")

# Download a file
with open('local_file.txt', 'wb') as f:
    remote_file = next(storage.files)  # Get first file
    remote_file.write_to(f)

# Upload a file
with open('local_upload.txt', 'rb') as f:
    storage.create_file('remote_path.txt', f)

Command-line usage:

# Set up project configuration
osf init

# List all files
osf ls

# Download all files
osf clone

# Download specific file
osf fetch remote/path.txt local/file.txt

# Upload file
osf upload local/file.txt remote/path.txt

Architecture

OSFClient is built around a hierarchical model structure:

  • OSF: Main client class for authentication and project access
  • Project: Represents an OSF project containing multiple storage providers
  • Storage: Individual storage provider (osfstorage, github, figshare, etc.)
  • File/Folder: Individual files and folders within storage
  • OSFSession: HTTP session management with rate limiting and authentication

This design mirrors the OSF platform's structure, providing intuitive navigation from projects down to individual files while supporting both programmatic access and command-line operations.

Capabilities

Python API

Core Python library functionality for programmatic access to OSF projects, including authentication, project management, and file operations.

class OSF:
    def __init__(self, username=None, password=None, token=None): ...
    def login(self, username=None, password=None, token=None): ...
    def project(self, project_id): ...
    def guid(self, guid): ...

Python API

Project Management

Project, storage, file, and folder management classes for navigating and manipulating OSF project structures.

class Project:
    def storage(self, provider='osfstorage'): ...
    @property
    def storages(self): ...

class Storage:
    def create_file(self, path, fp, force=False, update=False): ...
    def create_folder(self, name, exist_ok=False): ...
    @property
    def files(self): ...

Project Management

Command Line Interface

Full-featured CLI for OSF operations including project setup, file listing, downloading, uploading, and URL generation.

osf init                           # Set up project configuration
osf clone [output]                 # Download all files
osf fetch <remote> [local]         # Download specific file
osf list                          # List all files
osf upload <source> <destination>  # Upload file or directory
osf remove <target>               # Remove file
osf geturl <remote>               # Get download URL

CLI Interface

Utilities and Exceptions

Utility functions for path handling, file operations, and custom exception classes for error handling.

def norm_remote_path(path): ...
def split_storage(path, default='osfstorage'): ...
def checksum(file_path, hash_type='md5', block_size=65536): ...

class OSFException(Exception): ...
class UnauthorizedException(OSFException): ...

Utilities