Intro
LibSA4Py is a static analysis library for Python, which extracts type hints and features for training ML-based type inference models.
Requirements
- Python 3.7 or newer (Python 3.8 is recommended)
- Watchman (for running pyre) [Optional]
- MacOS or Linux systems
Quick Installation
git clone https://github.com/saltudelft/libsa4py.git
cd libsa4py && pip install .
Usage
Processing projects
Given Python repositories, run the following command to process source code files and generate JSON-formatted outputs:
libsa4py process --p $REPOS_PATH --o $OUTPUT_PATH --d $DUPLICATE_PATH --j $WORKERS_COUNT --l $LIMIT --c --no-nlp --pyre
Description:
--p $REPOS_PATH: The path to the Python corpus or dataset.--o $OUTPUT_PATH: Path to store processed projects.--d $DUPLICATE_PATH: Path to duplicate files of the given dataset (i.e. jsonl.gz file produced by the CD4Py tool). [Optional]--s: Path to the CSV file for splitting the given dataset. [Optional]--j $WORKERS_COUNT: Number of workers for processing projects. [Optional, default=no. of available CPU cores]--l $LIMIT: Number of projects to be processed. [Optional]--c: Whether to ignore processed projects. [Optional, default=False]--no-nlp: Whether to apply standard NLP techniques to extracted identifiers. [Optional, default=True]--pyre: Whether to runpyreto infer the types of variables for given projects. [Optional, default=False]--tc: Whether to type-check type annotations in projects. [Optional, default=False]
Merging projects
To merge all the processed JSON-formatted projects into a single dataframe, run the following command:
libsa4py merge --o $OUTPUT_PATH --l $LIMIT
Description:
--o $OUTPUT_PATH: Path to the processed projects, used in the previous processing step.--l $LIMIT: Number of projects to be merged. [Optional]
Applying types
To apply Pyre's inferred types to projects, run the following command:
libsa4py apply --p $REPOS_PATH --o $OUTPUT_PATH
Description:
--p $REPOS_PATH: The path to the Python corpus or dataset.--o $OUTPUT_PATH: Path to the processed projects, used in the previous processing step.
JSON Output
After processing each project, a JSON-formatted file is produced, which is described here.
Release files for libsa4py 0.4.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| libsa4py-0.4.0.tar.gz | 88.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| libsa4py-0.4.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 130.2 kB
Release files / libsa4py-0.4.0.tar.gz
| Download URL | libsa4py-0.4.0.tar.gz |
|---|---|
| Size | 88.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
953f4b2e2204af2bd5901f88779c0ed41287ba43e5f26096377b3507a0161163
|
|
BLAKE2b-256 checksum How to use checksums |
c843bed5e39db0ff9b18354c2764be54155e668a8acf0aca5b216bdbe2a92943
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.7.16
|
Release files / libsa4py-0.4.0-py3-none-any.whl
| Download URL | libsa4py-0.4.0-py3-none-any.whl |
|---|---|
| Size | 41.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
2c89559d5bcbedf75741b17c0c60ee2eb8ecf3d8273c54e61f19641ad94d160d
|
|
BLAKE2b-256 checksum How to use checksums |
60b5d68becae77e0e7c3417af0ea3a03ecfaa6d24af643e1712130bba4eee697
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.7.16
|