Skip to content

What's New in CANFAR

Stay up to date with the latest features, improvements, and changes in CANFAR.

Recent Updates

New in v1.1+

๐Ÿ›ก๏ธ Improved Session Data Validation

The CANFAR CLI now features enhanced resilience when handling session data from the Science Platform API. This update improves the user experience when the API returns incomplete or malformed session information.

What Changed:

  • Graceful Degradation: The CLI commands (canfar info, canfar ps) now continue to work even when the API returns incomplete session data, displaying partial information instead of crashing.
  • Better Error Reporting: Missing or invalid fields are tracked internally and can be viewed with the --debug flag for troubleshooting.
  • Enhanced Display: Resource usage metrics for flexible sessions is now reported with better readability.
  • Type Safety: Session type validation has been strengthened using Pydantic's built-in validators.

Example:

Flexible Session Resource Usage
$ canfar info n2tr1rpf

CANFAR Session Info for n2tr1rpf

  Session ID    n2tr1rpf
  Name          spy-panda
  Status        Running
  Type          notebook
  CPU Usage     0.001 core(s)
  RAM Usage     0.22 GB
  GPU Usage     Unknown # (GPU not requested)
Debug Mode for Troubleshooting
$ canfar info --debug n2tr1rpf 

# Shows additional warnings about missing/invalid fields
โš ๏ธ  Session Response Warnings:
    โ€ข missing or invalid startTime in response
    โ€ข missing or invalid expiryTime in response

v1.0

Breaking Changes

CLI Support

  • Comprehensive CLI support has been added to the client under the canfar entry point. See CLI Reference for more information.
  • The canfar CLI is the recommended way to manage authentication. See Authentication Contexts for more information.

๐ŸŒŽ SRCnet Support

  • CANFAR now supports launching sessions on all the SRCnet CANFAR Science Platform instances worldwide.

OIDC Authentication

  • OpenID Connect (OIDC) authentication is now supported for all SRCnet Science Platform servers where applicable.

Documentation

  • Complete overhaul to bring all documentation sources under a single roof.
  • Significant improvements to the Python client and brand new CLI documentation.

New in v0.7+

๐Ÿ” Enhanced Authentication System

Canfar now features a comprehensive authentication system with support for multiple authentication modes and automatic credential management.

Authentication Examples
from canfar.client import HTTPClient
from pathlib import Path

# X.509 certificate authentication
client = HTTPClient(certificate=Path("/path/to/cert.pem"))

# OIDC token authentication (configured)
client = HTTPClient()  # Uses auth.mode = "oidc"

# Bearer token authentication
from pydantic import SecretStr
client = HTTPClient(token=SecretStr("your-token"))

๐Ÿš€ Asynchronous Sessions

Canfar now supports asynchronous sessions using the AsyncSession class while maintaining 1-to-1 compatibility with the Session class.

Asynchronous Session Creation
from canfar.session import AsyncSession

asession = AsyncSession()
response = await asession.create(
    name="test",
    image="images.canfar.net/skaha/astroml:latest",
    cores=2,
    ram=8,
    gpu=1,
    kind="headless",
    cmd="env",
    env={"KEY": "VALUE"},
    replicas=3,
)

๐Ÿ—„๏ธ Backend Upgrades

  • ๐Ÿ“ก Canfar now uses the httpx library for making HTTP requests instead of requests. This adds asynchronous support and also to circumvent the requests dependence on urllib3 which was causing SSL issues on MacOS. See this issue for more details.
  • ๐Ÿ”‘ Canfar now supports multiple authentication methods including X.509 certificates, OIDC tokens, and bearer tokens with automatic SSL context management.
  • ๐ŸŽ๏ธ๐Ÿ’จ Added loglevel and concurrency support to manage the new explosion in functionality!
  • ๐Ÿ” Comprehensive debug logging for authentication flow and client creation troubleshooting.

๐Ÿงพ Logs to stdout

The [Session|AsyncSession].logs method now prints colored output to stdout instead of returning them as a string with verbose=True flag.

Session Logs
from canfar.session import AsyncSession

asession = AsyncSession()
await asession.logs(ids=["some-uuid"], verbose=True)

๐Ÿชฐ Firefly Support

Canfar now supports launching firefly session on the CANFAR Science Platform.

Firefly Session Creation
session.create(
    name="firefly",
    image="images.canfar.net/skaha/firefly:latest",
)

New in v0.4+

๐Ÿ” Private Images

Starting October 2024, to create a session with a private container image from the CANFAR Harbor Registry, you will need to provide your harbor username and the CLI Secret through a ContainerRegistry object.

Private Image Registry Configuration
from canfar.models import ContainerRegistry
from canfar.session import Session

registry = ContainerRegistry(username="username", secret="sUp3rS3cr3t")
session = Session(registry=registry)

Alternatively, if you have environment variables, CANFAR_REGISTRY_USERNAME and CANFAR_REGISTRY_SECRET, you can create a ContainerRegistry object without providing the username and secret.

Private Image Registry with Environment Variables
from canfar.models import ContainerRegistry

registry = ContainerRegistry()

๐Ÿ’ฃ Destroy Sessions

Destroying Sessions
from canfar.session import Session

session = Session()
session.destroy_with(prefix="test", kind="headless", status="Running")
session.destroy_with(prefix=".*-analysis", kind="headless", status="Pending")

Previous Versions

For a complete history of changes, see the Changelog.

Stay Updated