Skip to content

Commit 5669f08

Browse files
committed
Initial argument parser and defining classes at runtime
This allows us to define python decider classes at runtime Former-commit-id: 35f4cea
1 parent a6b611e commit 5669f08

File tree

7 files changed

+205
-0
lines changed

7 files changed

+205
-0
lines changed

.pydevproject

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2+
<?eclipse-pydev version="1.0"?><pydev_project>
3+
<pydev_property name="org.python.pydev.PYTHON_PROJECT_INTERPRETER">Default</pydev_property>
4+
<pydev_property name="org.python.pydev.PYTHON_PROJECT_VERSION">python 3.0</pydev_property>
5+
</pydev_project>

pom.xml

+48
Original file line numberDiff line numberDiff line change
@@ -894,6 +894,54 @@
894894
<artifactId>maven-source-plugin</artifactId>
895895
<version>2.2.1</version>
896896
</plugin>
897+
<!--This plugin's configuration is used to store Eclipse m2e settings only. It has no influence on the Maven build itself.-->
898+
<plugin>
899+
<groupId>org.eclipse.m2e</groupId>
900+
<artifactId>lifecycle-mapping</artifactId>
901+
<version>1.0.0</version>
902+
<configuration>
903+
<lifecycleMappingMetadata>
904+
<pluginExecutions>
905+
<pluginExecution>
906+
<pluginExecutionFilter>
907+
<groupId>org.jacoco</groupId>
908+
<artifactId>
909+
jacoco-maven-plugin
910+
</artifactId>
911+
<versionRange>
912+
[0.6.3.201306030806,)
913+
</versionRange>
914+
<goals>
915+
<goal>prepare-agent</goal>
916+
</goals>
917+
</pluginExecutionFilter>
918+
<action>
919+
<ignore></ignore>
920+
</action>
921+
</pluginExecution>
922+
<pluginExecution>
923+
<pluginExecutionFilter>
924+
<groupId>
925+
org.apache.maven.plugins
926+
</groupId>
927+
<artifactId>
928+
maven-checkstyle-plugin
929+
</artifactId>
930+
<versionRange>
931+
[2.12.1,)
932+
</versionRange>
933+
<goals>
934+
<goal>check</goal>
935+
</goals>
936+
</pluginExecutionFilter>
937+
<action>
938+
<ignore></ignore>
939+
</action>
940+
</pluginExecution>
941+
</pluginExecutions>
942+
</lifecycleMappingMetadata>
943+
</configuration>
944+
</plugin>
897945
</plugins>
898946
</pluginManagement>
899947

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#! /usr/bin/env python3
2+
import argparse
3+
from abc import ABCMeta, abstractmethod
4+
from argparse import PARSER
5+
6+
####################################################
7+
## This defines what methods are customizable
8+
## by decider developers.
9+
####################################################
10+
11+
12+
class AbstractDecider( metaclass=ABCMeta ):
13+
@abstractmethod
14+
def init (self, PARSER):
15+
pass
16+
@abstractmethod
17+
def provideTargetQuery (self):
18+
pass
19+
@abstractmethod
20+
def checkFileDetails (self):
21+
pass
22+
@abstractmethod
23+
def doFinalCheck(self):
24+
pass
25+
26+

scripts/deciders/basicDeciderImpl.py

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#! /usr/bin/env python3
2+
from abstractDeciderImpl import AbstractDecider
3+
4+
####################################################
5+
## This is an implementation of a barebones decider
6+
## usable for running simple workflows
7+
####################################################
8+
9+
class Decider (AbstractDecider):
10+
def init (self, PARSER):
11+
print("oogly")
12+
def provideTargetQuery (self):
13+
pass
14+
def checkFileDetails (self):
15+
pass
16+
def doFinalCheck(self):
17+
pass

scripts/deciders/deciderFramework.py

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#! /usr/bin/env python3
2+
import subprocess, sys, argparse, importlib
3+
from builtins import int
4+
5+
###################################################################
6+
## This is an implementation of a
7+
## decider framework. This class is not designed for inheritance.
8+
###################################################################
9+
10+
def __main():
11+
12+
parser = argparse.ArgumentParser(description='Run a SeqWare decider in order to schedule workflow runs')
13+
targetGroup = parser.add_mutually_exclusive_group(required=True)
14+
bigTargetGroup = targetGroup.add_mutually_exclusive_group()
15+
bigTargetGroup.add_argument('--all', help='Target the decider at all data in your SeqWare provenance report', action='store_true')
16+
smallTargetGroup = targetGroup.add_mutually_exclusive_group()
17+
supportedConstraints = ['study-name', 'lane-SWID', 'ius-SWID', 'sample-name', 'root-sample-name', 'sequencer-run-name', 'organism', 'processing-SWID']
18+
for constraint in supportedConstraints:
19+
smallTargetGroup.add_argument('--'+ constraint, help='Target the decider at a ' + constraint + ', can be specified multiple times', action='append')
20+
parser.add_argument('--test', help='Output commands for scheduling potential workflow runs instead of actually scheduling them', action='store_true')
21+
parser.add_argument('--host', help='Schedule onto a particular host')
22+
parser.add_argument('--launch-max', help='The maximum number of jobs to launch at once', default=sys.maxsize, type=int)
23+
parser.add_argument('--meta-types', help='The meta-type(s) of files to run a workflow with', action='append')
24+
parser.add_argument('--deciderImpl', help='The name of a Python class that contains the implementation of the decider', default='basicDeciderImpl')
25+
26+
27+
args = parser.parse_args()
28+
## for debugging print the arguments
29+
print(args)
30+
31+
decider = importlib.import_module(args.deciderImpl)
32+
Decider = getattr(decider, 'Decider')
33+
34+
deciderImpl = Decider()
35+
deciderImpl.init(parser)
36+
37+
38+
39+
40+
41+
__main()

seqware-admin-webservice/pom.xml

+35
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,41 @@
273273
</configuration>
274274
</plugin>
275275
</plugins>
276+
<pluginManagement>
277+
<plugins>
278+
<!--This plugin's configuration is used to store Eclipse m2e settings only. It has no influence on the Maven build itself.-->
279+
<plugin>
280+
<groupId>org.eclipse.m2e</groupId>
281+
<artifactId>lifecycle-mapping</artifactId>
282+
<version>1.0.0</version>
283+
<configuration>
284+
<lifecycleMappingMetadata>
285+
<pluginExecutions>
286+
<pluginExecution>
287+
<pluginExecutionFilter>
288+
<groupId>
289+
org.apache.maven.plugins
290+
</groupId>
291+
<artifactId>
292+
maven-dependency-plugin
293+
</artifactId>
294+
<versionRange>
295+
[2.8,)
296+
</versionRange>
297+
<goals>
298+
<goal>copy</goal>
299+
</goals>
300+
</pluginExecutionFilter>
301+
<action>
302+
<ignore></ignore>
303+
</action>
304+
</pluginExecution>
305+
</pluginExecutions>
306+
</lifecycleMappingMetadata>
307+
</configuration>
308+
</plugin>
309+
</plugins>
310+
</pluginManagement>
276311
</build>
277312
<repositories>
278313
<repository>

seqware-distribution/pom.xml

+33
Original file line numberDiff line numberDiff line change
@@ -160,5 +160,38 @@
160160
</plugin>
161161

162162
</plugins>
163+
<pluginManagement>
164+
<plugins>
165+
<!--This plugin's configuration is used to store Eclipse m2e settings only. It has no influence on the Maven build itself.-->
166+
<plugin>
167+
<groupId>org.eclipse.m2e</groupId>
168+
<artifactId>lifecycle-mapping</artifactId>
169+
<version>1.0.0</version>
170+
<configuration>
171+
<lifecycleMappingMetadata>
172+
<pluginExecutions>
173+
<pluginExecution>
174+
<pluginExecutionFilter>
175+
<groupId>org.jacoco</groupId>
176+
<artifactId>
177+
jacoco-maven-plugin
178+
</artifactId>
179+
<versionRange>
180+
[0.6.3.201306030806,)
181+
</versionRange>
182+
<goals>
183+
<goal>prepare-agent</goal>
184+
</goals>
185+
</pluginExecutionFilter>
186+
<action>
187+
<ignore></ignore>
188+
</action>
189+
</pluginExecution>
190+
</pluginExecutions>
191+
</lifecycleMappingMetadata>
192+
</configuration>
193+
</plugin>
194+
</plugins>
195+
</pluginManagement>
163196
</build>
164197
</project>

0 commit comments

Comments
 (0)