diff --git a/.github/workflows/annotator-build-test.yml b/.github/workflows/annotator-build-test.yml new file mode 100644 index 000000000..efa214c8c --- /dev/null +++ b/.github/workflows/annotator-build-test.yml @@ -0,0 +1,35 @@ +name: Bystro Annotator Build & Test + +on: pull_request + +jobs: + build: + runs-on: ubuntu-22.04 + + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Load cached Docker layers + uses: actions/cache@v3 + with: + path: /tmp/docker-layers + key: docker-layers-${{ runner.os }}-${{ hashFiles('Dockerfile') }} + restore-keys: | + docker-layers-${{ runner.os }}- + + - name: Build Docker image + run: | + # Check if there's a cache hit. If so, load from cache. + if [[ -d "/tmp/docker-layers" ]]; then + cat /tmp/docker-layers/*.tar | docker load + fi + docker build -t bystro . + + # Save Docker layers to cache. + mkdir -p /tmp/docker-layers + docker save bystro:latest | gzip -1 > /tmp/docker-layers/image.tar + + - name: Run tests in Docker container + run: | + docker run bystro prove /bystro/t/** diff --git a/bin/bystro-utils.pl b/bin/bystro-utils.pl index c5e45ec11..e87797be0 100755 --- a/bin/bystro-utils.pl +++ b/bin/bystro-utils.pl @@ -6,7 +6,7 @@ use lib './lib'; -use Getopt::Long; +use Getopt::Long 'HelpMessage'; use Path::Tiny qw/path/; use Pod::Usage; use YAML::XS qw/LoadFile/; @@ -37,17 +37,17 @@ GetOptions( 'c|config=s' => \$yaml_config, 'n|name=s' => \$names, - 'h|help' => \$help, 'u|util=s' => \$utilName, + 'm|maxThreads=i' => \$maxThreads, + 'h|help' => \$help, 'd|debug=i' => \$debug, 'o|overwrite' => \$overwrite, 'v|verbose=i' => \$verbose, 'r|dryRun' => \$dryRunInsertions, - 'm|maxThreads=i' => \$maxThreads, ); if ($help || !$yaml_config) { - Pod::Usage::pod2usage(); + HelpMessage(1); } if(!$names) { @@ -112,9 +112,15 @@ # config may be mutated, by the last utility $config = LoadFile($yaml_config); my $utilConfig = $config->{tracks}{tracks}[$trackIdx]{utils}[$utilIdx]; + my $trackName = $config->{tracks}{tracks}[$trackIdx]{name}; my $utilName = $utilConfig->{name}; - say $utilName; + + if (!$utilName) { + die "The `name` property must be specified for each utility; missing for track \`$trackName\`\'s utility at index $utilIdx"; + } + + say "Processing \`$trackName\` utility \`$utilName\`"; # Uppercase the first letter of the utility class name # aka user may specify "fetch" and we grab Utils::Fetch @@ -132,19 +138,17 @@ =head1 NAME -run_utils - Runs items in lib/Utils +bystro_utils - Runs items in lib/Utils =head1 SYNOPSIS -run_utils - --config - --name - [--debug] - [--verbose] - [--maxThreads] - [--dryRun] - [--overwrite] - [--help] +bystro_utils.pl + + -c|--config The configuration file path, e.g. "config/hg19.yml". + -n|--name (Optional) The track names you wish to run the utilities of. Comma separated. Example: "ref,refSeq,cadd". Defaults to all tracks if not specified. + -u|--util (Optional) A single utility name, e.g. "SortCadd". Defaults to all utils for the specified tracks if not specified. + -m|--maxThreads (Optional) The maximum number of threads to use. Defaults to the number of logical CPU cores on the machine. + --help (Optional) Display this help message and exit. =head1 DESCRIPTION diff --git a/lib/Utils/Base.pm b/lib/Utils/Base.pm index fc038c40f..7144a2734 100644 --- a/lib/Utils/Base.pm +++ b/lib/Utils/Base.pm @@ -16,6 +16,7 @@ use List::MoreUtils qw/first_index/; use YAML::XS qw/LoadFile Dump/; use Path::Tiny qw/path/; use Time::localtime; +use Sys::CpuAffinity; ############## Arguments accepted ############# # The track name that they want to use @@ -69,7 +70,9 @@ has verbose => (is => 'ro'); has dryRun => (is => 'ro', isa => 'Bool', default => 0); -has maxThreads => (is => 'ro', isa => 'Int', default => 8); +has maxThreads => (is => 'ro', isa => 'Int', lazy => 1, default => sub { + return Sys::CpuAffinity::getNumCpus(); +}); #########'Protected' vars (Meant to be used by child class only) ############ has _wantedTrack => ( is => 'ro', init_arg => undef, writer => '_setWantedTrack' ); diff --git a/lib/Utils/FilterCadd.pm b/lib/Utils/FilterCadd.pm index 3f36c2b95..065c08f3e 100644 --- a/lib/Utils/FilterCadd.pm +++ b/lib/Utils/FilterCadd.pm @@ -29,6 +29,8 @@ use Seq::Tracks::Score::Build; # Exports: _localFilesDir, _decodedConfig, compress, _wantedTrack, _setConfig, logPath, use_absolute_path extends 'Utils::Base'; +has '+compress' => (default => 1); + my $localFilesHandler = Seq::Tracks::Build::LocalFilesPaths->new(); sub BUILD {