comparison gcp_batch_netcat.py @ 3:0ea626b10557 draft

planemo upload for repository https://github.com/afgane/gcp_batch_netcat
author enis
date Mon, 21 Jul 2025 15:13:09 +0000
parents 79160beab2a4
children 2ff4a39ea41b
comparison
equal deleted inserted replaced
2:79160beab2a4 3:0ea626b10557
17 args = parser.parse_args() 17 args = parser.parse_args()
18 18
19 # Set up authentication using the service account key 19 # Set up authentication using the service account key
20 os.environ['GOOGLE_APPLICATION_CREDENTIALS'] = args.service_account_key 20 os.environ['GOOGLE_APPLICATION_CREDENTIALS'] = args.service_account_key
21 21
22 # Ensure gcloud uses a writable config directory
23 os.environ['CLOUDSDK_CONFIG'] = '/tmp/gcloud-config'
24
25 # Create the temp config directory if it doesn't exist
26 os.makedirs('/tmp/gcloud-config', exist_ok=True)
27
22 job_name = f'netcat-job-{uuid.uuid4()}' 28 job_name = f'netcat-job-{uuid.uuid4()}'
23 29
24 job_spec = { 30 job_spec = {
25 "taskGroups": [ 31 "taskGroups": [
26 { 32 {
27 "taskSpec": { 33 "taskSpec": {
28 "runnables": [ 34 "runnables": [
29 { 35 {
30 "script": { 36 "script": {
31 "text": f"nc -z -v {args.nfs_address} {args.port}" 37 "text": f"/usr/bin/nc -z -v {args.nfs_address} {args.port}"
32 } 38 }
33 } 39 }
34 ] 40 ],
41 "computeResource": {
42 "cpuMilli": 1000,
43 "memoryMib": 1024
44 },
45 "environment": {
46 "imageUri": "afgane/gcp-batch-netcat:0.1.0"
47 }
35 }, 48 },
36 "taskCount": 1, 49 "taskCount": 1,
37 "parallelism": 1 50 "parallelism": 1
38 } 51 }
39 ], 52 ],
49 command = [ 62 command = [
50 'gcloud', 'batch', 'jobs', 'submit', job_name, 63 'gcloud', 'batch', 'jobs', 'submit', job_name,
51 '--location', args.region, 64 '--location', args.region,
52 '--project', args.project, 65 '--project', args.project,
53 '--config', job_spec_file, 66 '--config', job_spec_file,
54 '--format=text' 67 '--format=text',
68 '--verbosity=debug'
55 ] 69 ]
56 70
57 # Wait 4 minutes before submitting the job 71 # Wait 4 minutes before submitting the job
58 time.sleep(240) 72 time.sleep(240)
59 73