Skip to content

Commit d230516

Browse files
committed
fix
1 parent 010ca7b commit d230516

File tree

9 files changed

+49
-28
lines changed

9 files changed

+49
-28
lines changed

.github/workflows/ci-mac.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,10 @@ jobs:
2323
run: |
2424
pip install invoke
2525
pip install -e tests/assets/my_project
26-
pip install https://github.com/ploomber/ploomber@cloud
26+
pip install git+https://github.com/ploomber/ploomber@cloud
2727
pip install ".[dev]"
28+
# one of airflow's dependencies is downgrading clic, which breaks ploomber
29+
pip install click --upgrade
2830
- name: Test with pytest
2931
env:
3032
PLOOMBER_STATS_ENABLED: false

.github/workflows/ci-windows.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,10 @@ jobs:
2323
run: |
2424
pip install invoke
2525
pip install -e tests/assets/my_project
26-
pip install https://github.com/ploomber/ploomber@cloud
26+
pip install git+https://github.com/ploomber/ploomber@cloud
2727
pip install ".[dev]"
28+
# one of airflow's dependencies is downgrading clic, which breaks ploomber
29+
pip install click --upgrade
2830
- name: Test with pytest
2931
env:
3032
PLOOMBER_STATS_ENABLED: false

.github/workflows/ci.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,10 @@ jobs:
2828
run: |
2929
pip install invoke
3030
pip install -e tests/assets/my_project
31-
pip install https://github.com/ploomber/ploomber@cloud
31+
pip install git+https://github.com/ploomber/ploomber@cloud
3232
pip install ".[dev]"
33+
# one of airflow's dependencies is downgrading clic, which breaks ploomber
34+
pip install click --upgrade
3335
- name: Test with pytest
3436
env:
3537
CLIENT_ID: ${{ secrets.CLIENT_ID }}

environment.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
dependencies:
2+
- a
3+
- b
4+
- pip: 1

soopervisor.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
2+
env:
3+
backend: backend-value

src/soopervisor/aws/batch.py

Lines changed: 27 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
"""
44
import json
55
from pathlib import Path
6-
from functools import partial
76

87
from ploomber.io._commander import Commander, CommanderStop
98
from ploomber.util.util import requires
@@ -50,7 +49,7 @@ def _submit_dag(
5049
container_properties,
5150
region_name,
5251
cmdr,
53-
call_api,
52+
is_cloud,
5453
):
5554
client = boto3.client('batch', region_name=region_name)
5655
container_properties['image'] = remote_name
@@ -65,14 +64,16 @@ def _submit_dag(
6564

6665
cmdr.info('Submitting jobs...')
6766

68-
# docker.build moves to the env folder
69-
params = json.loads(Path('../.ploomber-cloud').read_text())
70-
71-
out = api.runs_update(params['runid'], tasks)
67+
if is_cloud:
68+
# docker.build moves to the env folder
69+
params = json.loads(Path('../.ploomber-cloud').read_text())
70+
out = api.runs_update(params['runid'], tasks)
71+
else:
72+
out, params = None, None
7273

7374
for name, upstream in tasks.items():
7475

75-
if out:
76+
if is_cloud:
7677
ploomber_task = [
7778
'python',
7879
'-m',
@@ -98,16 +99,16 @@ def _submit_dag(
9899

99100
cmdr.print(f'Submitted task {name!r}...')
100101

101-
api.runs_register_ids(params['runid'], job_ids)
102-
103-
104-
submit_dag_no_api = partial(_submit_dag, call_api=False)
105-
submit_dag_api = partial(_submit_dag, call_api=True)
102+
if is_cloud:
103+
api.runs_register_ids(params['runid'], job_ids)
106104

107105

108106
class AWSBatchExporter(abc.AbstractExporter):
109107
CONFIG_CLASS = AWSBatchConfig
110-
SUBMIT_DAG = submit_dag_no_api
108+
109+
@classmethod
110+
def _submit_dag(cls, *args, **kwargs):
111+
return _submit_dag(*args, **kwargs, is_cloud=False)
111112

112113
@staticmethod
113114
def _validate(cfg, dag, env_name):
@@ -153,18 +154,22 @@ def _export(cls, cfg, env_name, mode, until, skip_tests, ignore_git):
153154

154155
cmdr.info('Submitting jobs to AWS Batch')
155156

156-
cls.SUBMIT_DAG(tasks=tasks,
157-
args=cli_args,
158-
job_def=pkg_name,
159-
remote_name=remote_name,
160-
job_queue=cfg.job_queue,
161-
container_properties=cfg.container_properties,
162-
region_name=cfg.region_name,
163-
cmdr=cmdr)
157+
cls._submit_dag(tasks=tasks,
158+
args=cli_args,
159+
job_def=pkg_name,
160+
remote_name=remote_name,
161+
job_queue=cfg.job_queue,
162+
container_properties=cfg.container_properties,
163+
region_name=cfg.region_name,
164+
cmdr=cmdr)
164165

165166
cmdr.success('Done. Submitted to AWS Batch')
166167

167168

169+
# TODO: add tests
168170
class CloudExporter(AWSBatchExporter):
169171
CONFIG_CLASS = CloudConfig
170-
SUBMIT_DAG = submit_dag_api
172+
173+
@classmethod
174+
def _submit_dag(cls, *args, **kwargs):
175+
return _submit_dag(*args, **kwargs, is_cloud=True)

tests/test_cli.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def monkeypatch_external(monkeypatch):
2222
monkeypatch.setattr(argo_export, 'Commander', CustomCommander)
2323
monkeypatch.setattr(airflow_export, 'Commander', CustomCommander)
2424
monkeypatch.setattr(batch, 'Commander', CustomCommander)
25-
monkeypatch.setattr(batch, 'submit_dag', Mock())
25+
monkeypatch.setattr(batch, '_submit_dag', Mock())
2626
mock_copy = Mock(wraps=docker.source.copy)
2727
monkeypatch.setattr(docker.source, 'copy', mock_copy)
2828
return mock_copy

tests/test_config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ def test_get_backend_invalid_backend_value(tmp_empty):
5151
expected = ("Misconfigured environment: 'invalid' is not a "
5252
"valid backend. backend must be one of: "
5353
"'aws_batch', 'aws_lambda', 'argo_workflows', "
54-
"'airflow', 'kubeflow', 'slurm'")
54+
"'airflow', 'kubeflow', 'slurm', 'cloud'")
5555
assert str(excinfo.value) == expected
5656

5757

tests/test_slurm_export.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,10 @@ def factory(value):
171171
mock.stdout = value
172172
return mock
173173

174-
run_mock = Mock(side_effect=[factory(b'0'), factory(b'1'), factory(b'2')])
174+
run_mock = Mock()
175+
run_mock.run = Mock(
176+
side_effect=[factory(
177+
b'0'), factory(b'1'), factory(b'2')])
175178
monkeypatch.setattr(commons, 'load_tasks', load_tasks_mock)
176179
monkeypatch.setattr(export, 'run', run_mock)
177180

0 commit comments

Comments
 (0)