Coder Social home page Coder Social logo

libsa4py's Introduction

Intro

PyPI version GH Workflow codecov

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 run pyre to 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.

libsa4py's People

Contributors

mir-am avatar gousiosg avatar

Stargazers

Francisco Boni avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.