Skip to main content

code2seq

JetBrains Research Github action: build Code style: black

PyTorch's implementation of code2seq model.

Installation

You can easily install model through the PIP:

pip install code2seq

Usage

Minimal code example to run the model:

from argparse import ArgumentParser

from omegaconf import DictConfig, OmegaConf
from pytorch_lightning import Trainer

from code2seq.data.path_context_data_module import PathContextDataModule
from code2seq.model import Code2Seq


def train(config: DictConfig):
    # Load data module
    data_module = PathContextDataModule(config.data_folder, config.data)
    data_module.prepare_data()
    data_module.setup()

    # Load model
    model = Code2Seq(
        config.model,
        config.optimizer,
        data_module.vocabulary,
        config.train.teacher_forcing
    )

    trainer = Trainer(max_epochs=config.hyper_parameters.n_epochs)
    trainer.fit(model, datamodule=data_module)


if __name__ == "__main__":
    __arg_parser = ArgumentParser()
    __arg_parser.add_argument("config", help="Path to YAML configuration file", type=str)
    __args = __arg_parser.parse_args()

    __config = OmegaConf.load(__args.config)
    train(__config)

Navigate to config directory to see examples of configs. If you have any questions, then feel free to open the issue.

Metadata

Release files for code2seq 1.2.0

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

Source distribution (sdist)

Source distribution for code2seq 1.2.0
File Size Uploaded
code2seq-1.2.0.tar.gz 14.1 kB Details

Built distribution (wheel)

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

Total release size: 35.8 kB

Release files / code2seq-1.2.0.tar.gz

Download URL code2seq-1.2.0.tar.gz
Size 14.1 kB
Tags Source
SHA-256 checksum
How to use checksums
8731bd3f2dbcd6100327b713a607e8fbd4f308c18b5d6a4b4c5eeacf086444d6
BLAKE2b-256 checksum
How to use checksums
ca8e7561ef92a269acc4c63629214df4aae212fa930c895052a5b078e84c22a6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.8

Release files / code2seq-1.2.0-py3-none-any.whl

Download URL code2seq-1.2.0-py3-none-any.whl
Size 21.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
04f057306107625d6dcad36401d9a8c781b61e06975f7e843f6ae1602494f157
BLAKE2b-256 checksum
How to use checksums
1083387279008bd35d2b3728e6b211a1d212d4323096f11d0cf7619d29afae3e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.8

Release history Release notifications | RSS feed

This release

1.2.0 This release

2 release files

1.1.1

2 release files

1.0.3

2 release files

1.0.2

2 release files

1.0.1

2 release files

1.0.0

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release files

0.0.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