Views:

SDKs > Python

This article explains how to install FINBOURNE Python SDKs, how to upgrade Python SDKs, what's included in the upgrade, and any other action you may be required to take.

Note the following:

  • We strongly recommend pinning SDKs to an exact version to control when you take updates and make your builds repeatable.
  • The master/main branch of an SDK may not always have the latest API version; there may, for example, also be v2 or v3 branches. We aim to keep master/main updated with the latest API version, but there may be some lead time while we deprecate older endpoints. Once we deprecate older API versions, the latest API version is moved to the master/main branch.

Installing the latest LUSID Python SDK (Dec. 2023)

As of December 2023, v2 is the latest major version of the LUSID Python SDK. You can install v2 of the LUSID Python SDK by using the following command:

$ pip install lusid-sdk

Upgrading to v2 from an earlier version

You can now upgrade to v2 of the following packages:

We recommend upgrading to v2 as soon as possible to ensure you have access to the latest features. Support for the previous version (1.x.x) will be maintained until the end of May 2024.

Note that you must upgrade all SDKs used in a particular process to v2 at the same time. A process that uses both the Scheduler and Drive SDKs, for example, must either use v1 of both SDKs or v2 of both SDKs; mixing major versions will lead to dependency conflicts.

LUSID SDK

You can upgrade from v1 to v2 of the LUSID Python SDK by using the following pip command:

$ pip install lusid-sdk

Users need to update their code to reflect the following v2 changes

Preview SDKs

This release discontinues publishing the LUSID Preview SDK, instead adding the Experimental and Beta lifecycle APIs to a single SDK. Note that making requests to Experimental and Beta APIs requires additional licences; for more details please contact support

Changes to extensions packages

v1 lusid.utilities package has been renamed as lusid.extensions. The package now supports asynchronous requests using the asyncio library and makes loading configuration more configurable and readable:

  • You can now build an asynchronous client using the ApiClientFactory. To close connections after use, we recommend making requests within a context using a with statement.
    from lusid import ApiClientFactory, ApplicationMetadataApi
    api_client_factory = ApiClientFactory()
    async with api_client_factory:
        api_instance = api_client_factory.build(ApplicationMetadataApi)
  • You can now pass in a list of configuration loaders to ApiClientFactory. We currently provide loaders for reading API configuration from environment variables, a secrets file or keyword arguments. For example:
    from lusid import (
        ApiClientFactory,
        ApplicationMetadataApi,
        EnvironmentVariablesConfigurationLoader,
        SecretsFileConfigurationLoader,
        ArgsConfigurationLoader
    )
    config_loaders = [
        EnvironmentVariablesConfigurationLoader(),
        SecretsFileConfigurationLoader(api_secrets_file="secrets.json"),
        ArgsConfigurationLoader(app_name="LUSIDPythonTest")
    ]
    api_client_factory = ApiClientFactory(config_loaders=config_loaders)
    async with api_client_factory:
        api_instance = api_client_factory.build(ApplicationMetadataApi)

    Note the following: 

    • Configuration loaders each return a dictionary of configuration keys and values. When keys are found by multiple configuration loaders, the last configuration loader to read the key overrides previous loaders.
    • Custom configuration loaders must implement the load_config method described in the configuration loader protocol.

Model arguments must be named

v2 of the LUSID Python SDK now uses Pydantic to perform runtime type checking on model objects. The v2 upgrade removes positional argument support; model arguments must now be named:

## v1 of the SDK...
python version = 'version_example' 
api_response = api_instance.get_excel_addin(version)

## ...might change as follows for v2 of the SDK...
python version = 'version_example' 
api_response = await api_instance.get_excel_addin(version=version) 

Function arguments are type checked

In v2, models are more strict with argument types, and calling a function with incorrect types now throws a validation error, for example: 

 2 validation errors for Model 
 is_required 
     Field required [type=missing, input_value={'list_of_ints': ['1', 2,...ew York'}, 'gt_int': 21}, input_type=dict] 
 gt_int 
     Input should be greater than 42 [type=greater_than, input_value=21, input_type=int] 

LUSID Python Tools

Currently, LUSID Python Tools is only available for use with v1 of the LUSID Python SDK.

Installing v1 of the LUSID Python SDK

Please note v1 of lusid-sdk and lusid-sdk-preview are discontinued from June 2024.

If you do need to install v1 of the LUSID Python SDK for any reason, note two packages are published:

  • lusid-sdk contains only APIs with a lifecycle status of Production or Early Access. You can install the v1 LUSID Python SDK by using the following pip command:
    $ pip install lusid-sdk<2
  • lusid-sdk-preview contains additional APIs with a lifecycle status of Experimental or Beta. You can install the LUSID Python Preview SDK by using the following pip command:
    $ pip install lusid-sdk-preview<2