| 16 | |
| 17 | class Algorithm(object): |
| 18 | def __init__(self, client, algoRef): |
| 19 | # Parse algoRef |
| 20 | algoRegex = re.compile(r"(?:algo://|/|)(\w+/.+)") |
| 21 | m = algoRegex.match(algoRef) |
| 22 | if m is not None: |
| 23 | self.client = client |
| 24 | self.path = m.group(1) |
| 25 | self.username = self.path.split("/")[0] |
| 26 | self.algoname = self.path.split("/")[1] |
| 27 | if len(self.path.split("/")) > 2: |
| 28 | self.version = self.path.split("/")[2] |
| 29 | self.url = '/v1/algo/' + self.path |
| 30 | self.query_parameters = {} |
| 31 | self.output_type = OutputType.default |
| 32 | else: |
| 33 | raise ValueError('Invalid algorithm URI: ' + algoRef) |
| 34 | |
| 35 | def set_options(self, timeout=300, stdout=False, output=OutputType.default, **query_parameters): |
| 36 | self.query_parameters = {'timeout': timeout, 'stdout': stdout} |