Skip to main content

LUSID_by_Finbourne

Lusid Feature Python Decorator Scanner

Description

This repository contains source code which provides a python decorator called 'lusid_feature', which can then be used within a python project to scan through all 'lusid_feature' decorator values in a desired project package. The runner will then produce an output text file of desired name and path with all lusid_feature codes.

The generated text file is then passed into a Lusid feature reporter python script, which maps the feature codes to full feature names and their implementation status, ultimately creating a visual features report across all Lusid SDKs.

Usage

Installing

Run:

pip install lusidfeature

Importing

This repository has two main functions that need to be imported for the scanner to work

  1. lusid_feature in lusid_feature.py - The decorator used with functions and methods
  2. extract_features_to_file(argv) in reporter - The function that extracts all decorator values and writes them to a file

Implementing lusid_feature decorator

When successfully imported, lusid_feature decorator can be used to decorate functions and methods in the following manner:

from lusidfeature import lusid_feature

@lusid_feature("F1")
def some_function():
    pass # function/method implementation

Rules around using lusid_feature decorator:

  • The decorator must always be called with brackets, and have a string value passed. It can optionally contain multiple values. Correct Usage: @lusid_feature("F1") or @lusid_feature("F1", "F2") Incorrect Usage:@lusid_feature
  • The decorator must not have an empty string passed. The following will throw an error: @lusid_feature("")
  • The decorator must not have duplicate feature values across the package files that are being scanned. The following will throw an error if both functions/methods with the same feature codes are found in the same package:
@lusid_feature("F1")
def some_function():
    pass # function/method implementation

@lusid_feature("F1")
def some_other_function():
    pass # function/method implementation

Running the decorator scanner

To extract the feature values and write them to a file, the following function must be imported and run from a main function in a main.py file:

from lusidfeature.reporter import extract_features_to_file

def main(argv):
    extract_features_to_file(argv)


if __name__ == "__main__":
    main(sys.argv)

The reason we must use 'if name == "main"' with an entry main function is because the decorator scanner must be run directly, together with strictly required "root project directory", "project package name" and "output file path" parameters.

Input parameters (sys.argv)

The command line requires two parameters

  • --outpath or -o
    This is the full qualified filename of where to create the output file

Examples:

Windows:

-o <your-absolute-path>\<your-filename>.txt

-o C:\\home\src\output\features.txt

Unix (Mac/Linux):

-o <your-absolute-path>/<your-filename>.txt

-o home/src/output/features.txt
  • --package or -p
    This is the package that the decorator scanner should look for decorators in Examples:
-p lusid.submodule
-p lusid.submodule.anothersubmodule
-p tests.tutorials
  • --root or -r
    The path of root directory from which the decorator scanner should start traversing packages and modules. The path must point to a directory within the project folder, and not to a directory outside the project. (Recommended to be the root SDK folder or src folder rather than the base project path.)

Examples:

Windows:

-r C:\\home\lusid-sdk-python\sdk

Unix (Mac/Linux):

-r home/lusid-sdk-python/sdk

To run, set your PYTHONPATH for the required folders and run the following example in a similar way:

python main.py -p "tests.tutorials" -o "/usr/app/features.txt"

Output file

The decorator scanner should write a file to the specified path with the example content:

features.txt

F1
F32
F2
F3
F10
F11
F8
etc...

Stacking decorators

Decorator stacking for lusid_feature is not supported at the moment. The following will NOT yield expected results.

Incorrect usage:

@lusid_feature("F1")
@lusid_feature("F2")
def some_function():
    pass # function/method implementation

Metadata

Release files for lusidfeature 0.2.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for lusidfeature 0.2.4
File Size Uploaded
lusidfeature-0.2.4.tar.gz 6.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for lusidfeature 0.2.4
File Interpreter ABI Platform
lusidfeature-0.2.4-py3-none-any.whl Python 3 none any Details

Total release size: 14.3 kB

Release files / lusidfeature-0.2.4.tar.gz

Download URL lusidfeature-0.2.4.tar.gz
Size 6.8 kB
Tags Source
SHA-256 checksum
How to use checksums
51efd3e4a58cb3d0c16c8989b36a6db72300342546d53b1afe247926aff5ade0
BLAKE2b-256 checksum
How to use checksums
566471d0da8a4d0030bbd6ba22ca12bfa2f158f88066be81896640a756faffaf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.9.5

Release files / lusidfeature-0.2.4-py3-none-any.whl

Download URL lusidfeature-0.2.4-py3-none-any.whl
Size 7.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
74c0be6be2e87a7999ddfa56ca365debf7247a0c9060f350b99f8f8871de9445
BLAKE2b-256 checksum
How to use checksums
0f74ac335734338c9b23a652fae6a0a66297da5e59b5b43370d1abf40d730f1b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.9.5

Release history Release notifications | RSS feed

This release

0.2.4 This release

2 release files

0.2.3

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.3

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page