-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #115 from naobservatory/dev
v2.5.2
- Loading branch information
Showing
75 changed files
with
862 additions
and
209 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
name: End-to-end MGS workflow test | ||
|
||
on: [pull_request] | ||
|
||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up JDK 11 | ||
uses: actions/setup-java@v4 | ||
with: | ||
java-version: '11' | ||
distribution: 'adopt' | ||
|
||
- name: Setup Nextflow latest-edge | ||
uses: nf-core/setup-nextflow@v1 | ||
with: | ||
version: "latest-edge" | ||
|
||
- name: Install nf-test | ||
run: | | ||
wget -qO- https://get.nf-test.com | bash | ||
sudo mv nf-test /usr/local/bin/ | ||
- name: Run index workflow | ||
run: nf-test test --tag index --verbose | ||
|
||
- name: Clean docker for more space | ||
run: | | ||
docker kill $(docker ps -q) 2>/dev/null || true | ||
docker rm $(docker ps -a -q) 2>/dev/null || true | ||
docker rmi $(docker images -q) -f 2>/dev/null || true | ||
docker system prune -af --volumes | ||
- name: Clean up nf-test dir | ||
run: sudo rm -rf .nf-test | ||
|
||
- name: Run run workflow | ||
run: nf-test test --tag run --verbose | ||
|
||
- name: Run run_validation workflow | ||
run: nf-test test --tag validation --verbose |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,3 +7,6 @@ test/output | |
test/.nextflow* | ||
*.Rhistory | ||
pipeline_report.txt | ||
|
||
.nf-test/ | ||
.nf-test.log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
#!/usr/bin/env python3 | ||
|
||
import argparse | ||
import json | ||
import boto3 | ||
import sys | ||
from botocore.exceptions import ClientError | ||
|
||
def load_lifecycle_config(config_path): | ||
try: | ||
with open(config_path, 'r') as f: | ||
return json.load(f) | ||
except json.JSONDecodeError: | ||
print(f"Error: {config_path} contains invalid JSON") | ||
sys.exit(1) | ||
except FileNotFoundError: | ||
print(f"Error: Could not find file {config_path}") | ||
sys.exit(1) | ||
|
||
def print_lifecycle_rules(rules): | ||
if not rules: | ||
print("No lifecycle rules configured") | ||
return | ||
|
||
for rule in rules: | ||
print(f"- {rule['ID']}") | ||
print(f" Status: {rule['Status']}") | ||
if 'Expiration' in rule: | ||
print(f" Expiration: {rule['Expiration'].get('Days', 'N/A')} days") | ||
print() | ||
|
||
def get_current_rules(s3, bucket_name): | ||
try: | ||
response = s3.get_bucket_lifecycle_configuration(Bucket=bucket_name) | ||
return response.get('Rules', []) | ||
except ClientError as e: | ||
if e.response['Error']['Code'] == 'NoSuchLifecycleConfiguration': | ||
return [] | ||
raise | ||
|
||
def apply_lifecycle_rules(bucket_name, lifecycle_config): | ||
s3 = boto3.client('s3') | ||
|
||
try: | ||
# First verify the bucket exists and we have access | ||
s3.head_bucket(Bucket=bucket_name) | ||
|
||
# Show current configuration | ||
print(f"\nCurrent lifecycle rules for bucket {bucket_name}:") | ||
current_rules = get_current_rules(s3, bucket_name) | ||
print_lifecycle_rules(current_rules) | ||
|
||
# Apply the new configuration | ||
s3.put_bucket_lifecycle_configuration( | ||
Bucket=bucket_name, | ||
LifecycleConfiguration=lifecycle_config | ||
) | ||
print(f"\nSuccessfully applied new lifecycle rules to bucket: {bucket_name}") | ||
|
||
# Show the updated configuration | ||
print("\nUpdated lifecycle rules:") | ||
new_rules = get_current_rules(s3, bucket_name) | ||
print_lifecycle_rules(new_rules) | ||
|
||
except ClientError as e: | ||
error_code = e.response.get('Error', {}).get('Code', 'Unknown') | ||
if error_code == '404': | ||
print(f"Error: Bucket {bucket_name} does not exist") | ||
elif error_code == '403': | ||
print(f"Error: Permission denied for bucket {bucket_name}") | ||
else: | ||
print(f"Error applying lifecycle rules: {str(e)}") | ||
sys.exit(1) | ||
|
||
def main(): | ||
parser = argparse.ArgumentParser(description='Apply S3 lifecycle rules to a bucket') | ||
parser.add_argument('config_file', help='Path to lifecycle configuration JSON file') | ||
parser.add_argument('bucket_name', help='Name of the S3 bucket') | ||
|
||
args = parser.parse_args() | ||
|
||
# Load the configuration | ||
lifecycle_config = load_lifecycle_config(args.config_file) | ||
|
||
# Apply the rules | ||
apply_lifecycle_rules(args.bucket_name, lifecycle_config) | ||
|
||
if __name__ == '__main__': | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.