Skip to content

submission

The submission creation helpers.

kelp.core.submission.create_submission_tar

Creates submission TAR archive.

Parameters:

Name Type Description Default
preds_dir Path

The directory with predictions.

required
output_dir Path

The output directory where the submission file will be saved.

required
submission_file_name str

The name of the submission file.

'submission.tar'
Source code in kelp/core/submission.py
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
def create_submission_tar(preds_dir: Path, output_dir: Path, submission_file_name: str = "submission.tar") -> None:
    """
    Creates submission TAR archive.

    Args:
        preds_dir: The directory with predictions.
        output_dir: The output directory where the submission file will be saved.
        submission_file_name: The name of the submission file.

    """
    # Create a TAR file
    with tarfile.open(output_dir / submission_file_name, "w") as tar:
        for fp in preds_dir.glob("*_kelp.tif"):
            tar.add(fp, arcname=fp.name)

    _logger.info(f"Submission TAR file '{(output_dir / submission_file_name).as_posix()}' created successfully.")

kelp.core.submission.main

Main entrypoint for creating submission from predictions directory.

Source code in kelp/core/submission.py
45
46
47
48
49
def main() -> None:
    """Main entrypoint for creating submission from predictions directory."""
    cfg = parse_args()
    cfg.output_dir.mkdir(exist_ok=True, parents=True)
    create_submission_tar(preds_dir=cfg.predictions_dir, output_dir=cfg.output_dir)

kelp.core.submission.parse_args

Parse command line arguments for making a submission file.

Source code in kelp/core/submission.py
16
17
18
19
20
21
22
23
24
def parse_args() -> SubmissionConfig:
    """Parse command line arguments for making a submission file."""
    parser = argparse.ArgumentParser()
    parser.add_argument("--predictions_dir", type=str, required=True)
    parser.add_argument("--output_dir", type=str, required=True)
    args = parser.parse_args()
    cfg = SubmissionConfig(**vars(args))
    cfg.log_self()
    return cfg