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.
- Installing the latest LUSID Python SDK (Dec. 2023)
- Installing v1 of the LUSID Python SDK
- Upgrading to v2
- Upgrades for other Python SDKs in the FINBOURNE platform are also available now.
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 bev2
orv3
branches. We aim to keepmaster
/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 themaster
/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 pip command:
$ pip install lusid-sdk
Click here if you are upgrading to v2 from an existing installation.
Installing v1 of the LUSID Python SDK
For v1 of the LUSID Python SDK, two packages are published:
lusid-sdk
contains only APIs with a lifecycle status of Production or Early Access. You can install the 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
Please note v1 of lusid-sdk
and lusid-sdk-preview
will be discontinued from June 2024.
Upgrading to v2
You can now upgrade to v2 of the following packages:
- LUSID SDK
- LUSID Python Tools
- Other Python SDKs in the FINBOURNE platform
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 awith
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
v2 of the LUSID Python SDK is accompanied by the release of v2 of the LUSID Python tools package - this package includes v2 of the LUSID Python SDK as a dependency. You can upgrade both packages by running the following pip command:
$ pip install lusidtools
Users need to update their code to reflect the following v2 changes:
Pandas version 2 is required
LUSID Python tools now depends on Pandas version 2 - please check the pandas documentation for breaking changes and new features.
Removal of checkargs
decorator
As v2 of the LUSID Python SDK includes runtime type checking provided by Pydantic, the checkargs
decorator has been removed from the LUSID Python tools package.