Skip to content

Commit c8123ca

Browse files
committed
Update tests and fix gitpython version
The gitpython version that was in use has a problem (see issue here: gitpython-developers/GitPython#983). As mentioned in the thread, this can be resolved by pinning the version to 3.1.x
1 parent f74a091 commit c8123ca

File tree

3 files changed

+17
-8
lines changed

3 files changed

+17
-8
lines changed

Diff for: setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"databricks-cli==0.9.0",
1717
"docker==4.0.2",
1818
"flake8==3.7.2",
19-
"gitpython==3.0.2",
19+
"gitpython==3.1.1",
2020
"jinja2==2.10.1",
2121
"kubernetes==10.0.1",
2222
"py4j==0.10.7",

Diff for: takeoff/azure/deploy_to_databricks.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
vol.Optional("config_file", default="databricks.json.j2"): str,
3030
vol.Optional("name", default=""): str,
3131
vol.Optional("lang", default="python"): vol.All(str, vol.In(["python", "scala"])),
32-
vol.Optional("run_immediately", default=True): bool,
32+
vol.Optional("run_stream_job_immediately", default=True): bool,
3333
vol.Optional("arguments", default=[{}]): [{}],
3434
vol.Optional("schedule"): {
3535
vol.Required("quartz_cron_expression"): str,
@@ -88,14 +88,14 @@ def deploy_to_databricks(self):
8888
job_name = f"{app_name}-{self.env.artifact_tag}"
8989
job_config = self.create_config(job_name, job)
9090
is_streaming = self._job_is_streaming(job_config)
91-
run_immediately = job["run_immediately"]
91+
run_stream_job_immediately = job["run_stream_job_immediately"]
9292

9393
logger.info("Removing old job")
9494
self.remove_job(self.env.artifact_tag, job_config=job, is_streaming=is_streaming)
9595

9696
logger.info("Submitting new job with configuration:")
9797
logger.info(pprint.pformat(job_config))
98-
self._submit_job(job_config, is_streaming, run_immediately)
98+
self._submit_job(job_config, is_streaming, run_stream_job_immediately)
9999

100100
def create_config(self, job_name: str, job_config: dict):
101101
common_arguments = dict(
@@ -192,11 +192,11 @@ def _kill_it_with_fire(self, job_id):
192192
logger.info(f"Canceling active runs {active_run_ids}")
193193
[self.runs_api.cancel_run(_) for _ in active_run_ids]
194194

195-
def _submit_job(self, job_config: dict, is_streaming: bool, run_immediately: bool):
195+
def _submit_job(self, job_config: dict, is_streaming: bool, run_stream_job_immediately: bool):
196196
job_resp = self.jobs_api.create_job(job_config)
197197
logger.info(f"Created Job with ID {job_resp['job_id']}")
198198

199-
if is_streaming or run_immediately:
199+
if is_streaming and run_stream_job_immediately:
200200
resp = self.jobs_api.run_now(
201201
job_id=job_resp["job_id"],
202202
jar_params=None,

Diff for: tests/azure/test_deploy_to_databricks.py

+11-2
Original file line numberDiff line numberDiff line change
@@ -599,12 +599,14 @@ def test_kill_it_with_fire(self, victim):
599599
victim.runs_api.cancel_run.assert_has_calls(calls)
600600

601601
def test_submit_job_batch(self, victim):
602-
victim._submit_job({}, False)
602+
victim._submit_job({}, False, True)
603603

604604
victim.jobs_api.create_job.assert_called_with({})
605605

606+
victim.jobs_api.run_now.assert_not_called()
607+
606608
def test_submit_job_streaming(self, victim):
607-
victim._submit_job({}, True)
609+
victim._submit_job({}, True, True)
608610

609611
victim.jobs_api.create_job.assert_called_with({})
610612

@@ -615,3 +617,10 @@ def test_submit_job_streaming(self, victim):
615617
python_params=None,
616618
spark_submit_params=None,
617619
)
620+
621+
def test_submit_job_streaming_without_immediate_run(self, victim):
622+
victim._submit_job({}, True, False)
623+
624+
victim.jobs_api.create_job.assert_called_with({})
625+
626+
victim.jobs_api.run_now.assert_not_called()

0 commit comments

Comments
 (0)