Skip to content

Commit 2c0ce92

Browse files
Initial commit: Add multilspy files from github.com/microsoft/monitors4codegen repository
1 parent 70a3a97 commit 2c0ce92

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+15055
-15
lines changed

.github/workflows/codeql.yml

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
# For most projects, this workflow file will not need changing; you simply need
2+
# to commit it to your repository.
3+
#
4+
# You may wish to alter this file to override the set of languages analyzed,
5+
# or to provide custom queries or build logic.
6+
#
7+
# ******** NOTE ********
8+
# We have attempted to detect the languages in your repository. Please check
9+
# the `language` matrix defined below to confirm you have the correct set of
10+
# supported CodeQL languages.
11+
#
12+
name: "CodeQL"
13+
14+
on:
15+
push:
16+
branches: [ "main" ]
17+
pull_request:
18+
# The branches below must be a subset of the branches above
19+
branches: [ "main" ]
20+
schedule:
21+
- cron: '22 13 * * 2'
22+
23+
jobs:
24+
analyze:
25+
name: Analyze
26+
# Runner size impacts CodeQL analysis time. To learn more, please see:
27+
# - https://gh.io/recommended-hardware-resources-for-running-codeql
28+
# - https://gh.io/supported-runners-and-hardware-resources
29+
# - https://gh.io/using-larger-runners
30+
# Consider using larger runners for possible analysis time improvements.
31+
runs-on: ${{ (matrix.language == 'swift' && 'macos-latest') || 'ubuntu-latest' }}
32+
timeout-minutes: ${{ (matrix.language == 'swift' && 120) || 360 }}
33+
permissions:
34+
actions: read
35+
contents: read
36+
security-events: write
37+
38+
strategy:
39+
fail-fast: false
40+
matrix:
41+
language: [ 'python' ]
42+
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby', 'swift' ]
43+
# Use only 'java' to analyze code written in Java, Kotlin or both
44+
# Use only 'javascript' to analyze code written in JavaScript, TypeScript or both
45+
# Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support
46+
47+
steps:
48+
- name: Checkout repository
49+
uses: actions/checkout@v3
50+
51+
# Initializes the CodeQL tools for scanning.
52+
- name: Initialize CodeQL
53+
uses: github/codeql-action/init@v2
54+
with:
55+
languages: ${{ matrix.language }}
56+
# If you wish to specify custom queries, you can do so here or in a config file.
57+
# By default, queries listed here will override any specified in a config file.
58+
# Prefix the list here with "+" to use these queries and those in the config file.
59+
60+
# For more details on CodeQL's query packs, refer to: https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
61+
# queries: security-extended,security-and-quality
62+
63+
64+
# Autobuild attempts to build any compiled languages (C/C++, C#, Go, Java, or Swift).
65+
# If this step fails, then you should remove it and run the build manually (see below)
66+
- name: Autobuild
67+
uses: github/codeql-action/autobuild@v2
68+
69+
# ℹ️ Command-line programs to run using the OS shell.
70+
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
71+
72+
# If the Autobuild fails above, remove it and uncomment the following three lines.
73+
# modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance.
74+
75+
# - run: |
76+
# echo "Run, Build Application using script"
77+
# ./location_of_script_within_repo/buildscript.sh
78+
79+
- name: Perform CodeQL Analysis
80+
uses: github/codeql-action/analyze@v2
81+
with:
82+
category: "/language:${{matrix.language}}"

CITATION.cff

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
# This CITATION.cff file was generated with cffinit.
2+
# Visit https://bit.ly/cffinit to generate yours today!
3+
4+
cff-version: 1.2.0
5+
title: >-
6+
Monitor-Guided Decoding of Code LMs with Static Analysis
7+
of Repository Context
8+
message: >-
9+
If you use this repository, please cite it using the metadata
10+
from this file.
11+
type: dataset
12+
authors:
13+
- given-names: Lakshya A
14+
family-names: Agrawal
15+
16+
affiliation: Microsoft Research
17+
orcid: 'https://orcid.org/0000-0003-0409-8212'
18+
- given-names: Aditya
19+
family-names: Kanade
20+
21+
affiliation: Microsoft Research
22+
- given-names: Navin
23+
family-names: Goyal
24+
25+
affiliation: Microsoft Research
26+
- given-names: Shuvendu K.
27+
family-names: Lahiri
28+
29+
affiliation: Microsoft Research
30+
- given-names: Sriram K.
31+
family-names: Rajamani
32+
33+
affiliation: Microsoft Research
34+
identifiers:
35+
- type: doi
36+
value: 10.48550/arXiv.2306.10763
37+
- type: url
38+
value: >-
39+
https://openreview.net/forum?id=qPUbKxKvXq&noteId=98Ukj82fSP
40+
abstract: >-
41+
Language models of code (LMs) work well when the
42+
surrounding code provides sufficient context. This is not
43+
true when it becomes necessary to use types, functionality
44+
or APIs defined elsewhere in the repository or a linked
45+
library, especially those not seen during training. LMs
46+
suffer from limited awareness of such global context and
47+
end up hallucinating.
48+
49+
50+
Integrated development environments (IDEs) assist
51+
developers in understanding repository context using
52+
static analysis. We extend this assistance, enjoyed by
53+
developers, to LMs. We propose monitor-guided decoding
54+
(MGD) where a monitor uses static analysis to guide the
55+
decoding. We construct a repository-level dataset
56+
PragmaticCode for method-completion in Java and evaluate
57+
MGD on it. On models of varying parameter scale, by
58+
monitoring for type-consistent object dereferences, MGD
59+
consistently improves compilation rates and agreement with
60+
ground truth. Further, LMs with fewer parameters, when
61+
augmented with MGD, can outperform larger LMs. With MGD,
62+
SantaCoder-1.1B achieves better compilation rate and
63+
next-identifier match than the much larger
64+
text-davinci-003 model.
65+
66+
67+
We also conduct a generalizability study to evaluate the
68+
ability of MGD to generalize to multiple programming
69+
languages (Java, C# and Rust), coding scenarios (e.g.,
70+
correct number of arguments to method calls), and to
71+
enforce richer semantic constraints (e.g., stateful API
72+
protocols). Our data and implementation are available at
73+
https://github.com/microsoft/monitors4codegen.
74+
keywords:
75+
- program analysis
76+
- correctness
77+
- code generation
78+
- Language models

SUPPORT.md

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,3 @@
1-
# TODO: The maintainer of this repo has not yet edited this file
2-
3-
**REPO OWNER**: Do you want Customer Service & Support (CSS) support for this product/project?
4-
5-
- **No CSS support:** Fill out this template with information about how to file issues and get help.
6-
- **Yes CSS support:** Fill out an intake form at [aka.ms/onboardsupport](https://aka.ms/onboardsupport). CSS will work with/help you to determine next steps.
7-
- **Not sure?** Fill out an intake as though the answer were "Yes". CSS will help you decide.
8-
9-
*Then remove this first heading from this SUPPORT.MD file before publishing your repo.*
10-
111
# Support
122

133
## How to file issues and get help
@@ -16,10 +6,7 @@ This project uses GitHub Issues to track bugs and feature requests. Please searc
166
issues before filing new issues to avoid duplicates. For new issues, file your bug or
177
feature request as a new Issue.
188

19-
For help and questions about using this project, please **REPO MAINTAINER: INSERT INSTRUCTIONS HERE
20-
FOR HOW TO ENGAGE REPO OWNERS OR COMMUNITY FOR HELP. COULD BE A STACK OVERFLOW TAG OR OTHER
21-
CHANNEL. WHERE WILL YOU HELP PEOPLE?**.
9+
For help and questions about using this project, please create an issue with the label "question".
2210

2311
## Microsoft Support Policy
24-
25-
Support for this **PROJECT or PRODUCT** is limited to the resources listed above.
12+
Support for `multilspy` is limited to the resources listed above.

azure-pipelines.yml

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# Starter pipeline
2+
# Start with a minimal pipeline that you can customize to build and deploy your code.
3+
# Add steps that build, run tests, deploy, and more:
4+
# https://aka.ms/yaml
5+
6+
trigger:
7+
- main
8+
9+
pool:
10+
vmImage: ubuntu-latest
11+
12+
steps:
13+
- script: echo Hello, world!
14+
displayName: 'Run a one-line script'
15+
16+
- script: |
17+
echo Add other tasks to build, test, and deploy your project.
18+
echo See https://aka.ms/yaml
19+
displayName: 'Run a multi-line script'
20+
21+
- task: ComponentGovernanceComponentDetection@0
22+
inputs:
23+
scanType: 'Register'
24+
verbosity: 'Verbose'
25+
alertWarningLevel: 'High'
26+
27+
- task: CodeQL3000Init@0
28+
- task: CodeQL3000Finalize@0
29+
30+
# - task: CredScan@2
31+
# inputs:
32+
# toolMajorVersion: 'V2'
33+
34+
# - task: ESLint@1
35+
# inputs:
36+
# Configuration: 'recommended'
37+
# TargetType: 'eslint'
38+
# ErrorLevel: 'warn'
39+
40+
# - task: Semmle@0
41+
# env:
42+
# SYSTEM_ACCESSTOKEN: $(System.AccessToken)
43+
# inputs:
44+
# sourceCodeDirectory: '$(Build.SourcesDirectory)'
45+
# language: 'tsandjs'
46+
# includeNodeModules: true
47+
# querySuite: 'Recommended'
48+
# timeout: '1800'
49+
# ram: '16384'
50+
# addProjectDirToScanningExclusionList: true
51+
52+
# - task: Semmle@1
53+
# inputs:
54+
# sourceCodeDirectory: '$(Build.SourcesDirectory)'
55+
# language: 'python'
56+
# querySuite: 'Recommended'
57+
# timeout: '1800'
58+
# ram: '16384'
59+
# addProjectDirToScanningExclusionList: true

pyproject.toml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Read https://setuptools.pypa.io/en/latest/userguide/datafiles.html
2+
[build-system]
3+
requires = ["flit_core>=3.4"]
4+
build-backend = "flit_core.buildapi"
5+
6+
[project]
7+
name = "multilspy"
8+
version = "0.0.1"
9+
authors = [
10+
{ name="Lakshya A Agrawal", email="[email protected]" },
11+
]
12+
description = "A language-agnostic LSP client in Python, with a library interface. Intended to be used to build applications around language servers. Currently multilspy supports language servers for Python, Rust, Java and C#. Originally appeared as part of Monitor-Guided Decoding (https://github.com/microsoft/monitors4codegen)"
13+
readme = "README.md"
14+
requires-python = ">=3.7"
15+
classifiers = [
16+
"Programming Language :: Python :: 3",
17+
"Operating System :: OS Independent",
18+
"Development Status :: 2 - Pre-Alpha",
19+
"Topic :: Software Development",
20+
"Topic :: Text Editors :: Integrated Development Environments (IDE)",
21+
"Programming Language :: C#",
22+
"Programming Language :: Java",
23+
"Programming Language :: Python",
24+
"Programming Language :: Rust"
25+
]
26+
27+
dependencies = [
28+
"jedi-language-server==0.41.1",
29+
"pydantic==1.10.5",
30+
"requests==2.32.3"
31+
]
32+
33+
[project.urls]
34+
"Homepage" = "https://github.com/microsoft/multilspy"
35+
"Bug Tracker" = "https://github.com/microsoft/multilspy/issues"
36+
37+
[tool.setuptools]
38+
include-package-data = true
39+
40+
[tool.setuptools.packages.find]
41+
where = ["src"]

requirements.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
jedi-language-server==0.41.1
2+
pytest==7.3.1
3+
pydantic==1.10.5
4+
pytest-asyncio==0.21.1
5+
requests==2.32.3

src/multilspy/__init__.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
"""
2+
This module contains the multilspy API
3+
"""
4+
5+
from . import multilspy_types as Types
6+
from .language_server import LanguageServer, SyncLanguageServer
7+
8+
__all__ = ["LanguageServer", "Types", "SyncLanguageServer"]

0 commit comments

Comments
 (0)