Git Product home page Git Product logo

dpu-utils's Introduction

DPU Utilities

Build Status

This contains a set of utilities used across projects of the DPU team.

Python

Stored in the python subdirectory, published as the dpu-utils package.

Installation

pip install dpu-utils

Overview of Utilities:

Generic Utilities:

  • dpu_utils.utils.RichPath a convenient way of using both paths and Azure paths in your code.
  • dpu_utils.utils.*Iterator iterator wrappers that can parallelize their iteration in other threads/processes.
  • dpu_utils.utils.{load,save}_json[l]_gz convenience methods for loading .json[l].gz from the filesystem.
  • dpu_utils.utils.git_tag_run that tags the current working directory git the state of the code.
  • dpu_utils.utils.run_and_debug when an exception happens, start a debug session. Usually a wrapper of __main__.
  • dpu_utils.utils.ChunkWriter that helps writing chunks to the output.

TensorFlow Utilities:

  • dpu_utils.tfutils.GradRatioLoggingOptimizer a wrapper around optimizers that logs the ratios of grad norms to parameter norms.
  • dpu_utils.tfutils.unsorted_segment_logsumexp
  • dpu_utils.tfutils.unsorted_segment_log_softmax
  • dpu_utils.tfutils.TFVariableSaver save TF variables in an object that can be pickled.

General Machine Learning Utilities:

  • dpu_utils.mlutils.CharTensorizer for character-level tensorization.
  • dpu_utils.mlutils.Vocabulary a str to int vocabulary for machine learning models

TensorFlow Models:

  • dpu_utils.tfmodels.SparseGGNN a sparse GGNN implementation.
  • dpu_utils.tfmodels.AsyncGGNN an asynchronous GGNN implementation.

Code-related Utilities

  • dpu_utils.codeutils.split_identifier_into_parts() split identifiers into subtokens on CamelCase and snake_case.
  • dpu_utils.codeutils.{Lattice, CSharpLattice} represent lattices and some useful operations in Python.
  • dpu_utils.codeutils.get_language_keywords() that retrieves the keyword tokens for many programming languages.
  • dpu_utils.codeutils.deduplication.DuplicateDetector that detects duplicates in codebases.

Command-line tools

Approximate Duplicate Code Detection

You can use the deduplicationcli command to detect duplicates in pre-processed source code, by invoking

deduplicationcli DATA_PATH OUT_JSON

where DATA_PATH is a file containing tokenized .jsonl.gz files and OUT_JSON is the target output file. For more options look at --help.

An exact (but usually slower) version of this can be found here along with code to tokenize Java, C#, Python and JavaScript into the relevant formats.

Tests

Run the unit tests

python setup.py test

Generate code coverage reports

# pip install coverage
coverage run --source dpu_utils/ setup.py test && \
  coverage html

The resulting HTML file will be in htmlcov/index.html.

.NET

Stored in the dotnet subdirectory.

Generic Utilities:

  • Microsoft.Research.DPU.Utils.RichPath: a convenient way of using both paths and Azure paths in your code.

Code-related Utilities:

  • Microsoft.Research.DPU.CSharpSourceGraphExtraction: infrastructure to extract Program Graphs from C# projects.

Contributing

This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.microsoft.com.

When you submit a pull request, a CLA-bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact [email protected] with any additional questions or comments.

dpu-utils's People

Contributors

asvyatkovskiy avatar azure-pipelines[bot] avatar jdayton3 avatar mallamanis avatar mmjb avatar rishad-sayone avatar

Watchers

 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.