diff --git a/pyproject.toml b/pyproject.toml index bc5fa9f..7b4ae31 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -8,7 +8,7 @@ dependencies = [ "click<9.0.0,>=8.1.3", "requests<3.0.0,>=2.32.0", "loguru<1.0.0,>=0.6.0", - "deepdiff<7.0.0,>=6.2.2", + "deepdiff>=8.0.0,<9.0.0", "pydantic<3.0.0,>=2.0.0", "croniter<2.0.0,>=1.3.8", "ruamel-yaml<1.0.0,>=0.17.21", @@ -20,7 +20,7 @@ dependencies = [ "importlib-metadata<7,>=6.0", ] name = "dbt-jobs-as-code" -version = "1.0.0" +version = "1.0.1" description = "A CLI to allow defining dbt Cloud jobs as code" readme = "README.md" keywords = [ diff --git a/src/dbt_jobs_as_code/schemas/__init__.py b/src/dbt_jobs_as_code/schemas/__init__.py index 10fcc33..22867a4 100644 --- a/src/dbt_jobs_as_code/schemas/__init__.py +++ b/src/dbt_jobs_as_code/schemas/__init__.py @@ -42,8 +42,14 @@ def check_job_mapping_same(source_job: JobDefinition, dest_job: JobDefinition) - logger.success(f"✅ Job {source_job.identifier} is identical") return True else: + # we can't json.dump types normally, so we provide a custom logic to just return the type name + def type_serializer(obj): + if isinstance(obj, type): + return obj.__name__ + raise TypeError(f"Object of type {type(obj).__name__} is not JSON serializable") + logger.info( - f"❌ Job {source_job.identifier} is different - Diff:\n{json.dumps(diffs, indent=2)}" + f"❌ Job {source_job.identifier} is different - Diff:\n{json.dumps(diffs, indent=2, default=type_serializer)}" ) return False diff --git a/tests/schemas/test_check_job_mapping_same.py b/tests/schemas/test_check_job_mapping_same.py new file mode 100644 index 0000000..7549342 --- /dev/null +++ b/tests/schemas/test_check_job_mapping_same.py @@ -0,0 +1,34 @@ +from dbt_jobs_as_code.schemas import check_job_mapping_same +from dbt_jobs_as_code.schemas.job import JobDefinition + + +def test_check_job_mapping_same(): + mock_job1 = JobDefinition( + id=1, + name="Job 1", + project_id=100, + environment_id=200, + account_id=300, + settings={}, + run_generate_sources=False, + execute_steps=[], + generate_docs=False, + schedule={"cron": "0 14 * * 0,1,2,3,4,5,6"}, + triggers={}, + ) + mock_job2 = JobDefinition( + id=2, + name="Job 2", + project_id=100, + environment_id=400, + account_id=300, + deferring_environment_id=400, + settings={}, + run_generate_sources=False, + execute_steps=[], + generate_docs=False, + schedule={"cron": "0 14 * * 0,1,2,3,4,5,6"}, + triggers={}, + ) + + assert check_job_mapping_same(mock_job1, mock_job2) == False diff --git a/uv.lock b/uv.lock index 45b362a..9428949 100644 --- a/uv.lock +++ b/uv.lock @@ -276,7 +276,7 @@ requires-dist = [ { name = "beartype", specifier = ">=0.18.5,<1.0.0" }, { name = "click", specifier = ">=8.1.3,<9.0.0" }, { name = "croniter", specifier = ">=1.3.8,<2.0.0" }, - { name = "deepdiff", specifier = ">=6.2.2,<7.0.0" }, + { name = "deepdiff", specifier = ">=8.0.0,<9.0.0" }, { name = "importlib-metadata", specifier = ">=6.0,<7" }, { name = "jinja2", specifier = ">=3.1.4,<4.0.0" }, { name = "loguru", specifier = ">=0.6.0,<1.0.0" }, @@ -300,14 +300,14 @@ dev = [ [[package]] name = "deepdiff" -version = "6.7.1" +version = "8.0.1" source = { registry = "https://pypi.org/simple" } dependencies = [ - { name = "ordered-set" }, + { name = "orderly-set" }, ] -sdist = { url = "https://files.pythonhosted.org/packages/52/11/d265eb046685fe97538e39f71d16d58a1197ddbd59873e06167bcfba8a89/deepdiff-6.7.1.tar.gz", hash = "sha256:b367e6fa6caac1c9f500adc79ada1b5b1242c50d5f716a1a4362030197847d30", size = 409107 } +sdist = { url = "https://files.pythonhosted.org/packages/62/ba/aced1d6a7d988ca1b6f9b274faed7dafc7356a733e45a457819bddcf2dbc/deepdiff-8.0.1.tar.gz", hash = "sha256:245599a4586ab59bb599ca3517a9c42f3318ff600ded5e80a3432693c8ec3c4b", size = 427721 } wheels = [ - { url = "https://files.pythonhosted.org/packages/5a/8f/a9d39ec15f40e8169cb134317824ee4618b864b2e4b91a9b310d3ef94729/deepdiff-6.7.1-py3-none-any.whl", hash = "sha256:58396bb7a863cbb4ed5193f548c56f18218060362311aa1dc36397b2f25108bd", size = 76554 }, + { url = "https://files.pythonhosted.org/packages/06/46/01673060e83277a863baf0909b387cd809865cba2d5e7213db76516bedd9/deepdiff-8.0.1-py3-none-any.whl", hash = "sha256:42e99004ce603f9a53934c634a57b04ad5900e0d8ed0abb15e635767489cbc05", size = 82741 }, ] [[package]] @@ -470,12 +470,12 @@ wheels = [ ] [[package]] -name = "ordered-set" -version = "4.1.0" +name = "orderly-set" +version = "5.2.2" source = { registry = "https://pypi.org/simple" } -sdist = { url = "https://files.pythonhosted.org/packages/4c/ca/bfac8bc689799bcca4157e0e0ced07e70ce125193fc2e166d2e685b7e2fe/ordered-set-4.1.0.tar.gz", hash = "sha256:694a8e44c87657c59292ede72891eb91d34131f6531463aab3009191c77364a8", size = 12826 } +sdist = { url = "https://files.pythonhosted.org/packages/c8/71/5408fee86ce5408132a3ece6eff61afa2c25d5b37cd76bc100a9a4a4d8dd/orderly_set-5.2.2.tar.gz", hash = "sha256:52a18b86aaf3f5d5a498bbdb27bf3253a4e5c57ab38e5b7a56fa00115cd28448", size = 19103 } wheels = [ - { url = "https://files.pythonhosted.org/packages/33/55/af02708f230eb77084a299d7b08175cff006dea4f2721074b92cdb0296c0/ordered_set-4.1.0-py3-none-any.whl", hash = "sha256:046e1132c71fcf3330438a539928932caf51ddbc582496833e23de611de14562", size = 7634 }, + { url = "https://files.pythonhosted.org/packages/69/71/6f9554919da608cb5bcf709822a9644ba4785cc7856e01ea375f6d808774/orderly_set-5.2.2-py3-none-any.whl", hash = "sha256:f7a37c95a38c01cdfe41c3ffb62925a318a2286ea0a41790c057fc802aec54da", size = 11621 }, ] [[package]]