facebook / facebook/pyrefly

Feature Request: compress baseline file

Open
#4,014 2 comments 0 reactions 0 assignees View on GitHub
baseline
Dominant language
Rust
Stars
7k
Forks
516
PR merge metrics
No merged PRs in 30d

Description

## Background

The baseline file can be quite large and is extremely compressible:

```
$ gzip -c .pyrefly_baseline.json > .pyrefly_baseline.json.gz
$ ll .pyrefly_baseline.json*
-rw-r----- 1 dthor primarygroup 9.3M Jul 1 17:08 .pyrefly_baseline.json
-rw-r----- 1 dthor primarygroup 510K Jul 2 04:05 .pyrefly_baseline.json.gz
```

9.3M to 510K.

## FR Summary:

Add an optional automatic gzip & gunzip (or other compression) action to the baseline file.

## Implementation Options

### 1. Intelligent based on file name and/or file type

If `--baseline` ends in `.gz`, then make the baseline and then `gzip` it. When consuming, automatically `gunzip` it. If `--baseline` ends in `bz2`, apply that (un)compression method instead. Etc.

Consuming should probably also check the file type because it's possible that people pass a gzipped-file-without-gz-extension.

```
$ file .pyrefly_baseline.json_wrong_ext
.pyrefly_baseline.json_wrong_ext: gzip compressed data, was ".pyrefly_baseline.json", last modified: Wed Jul 1 17:08:24 2026, from Unix, original size modulo 2^32 9741179
```

### 2. CLI arg

Add a `--compress-baseline` CLI arg. Maybe even optionally take a compression method, but I don't really see much use for such.

If the baseline file cannot be uncompressed using the method (eg someone passed a bz2 file to `--baseline` but `--compress-baseline=gz`), throw an error.

### 3. Umm...

I don't have any other ideas.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.