Skip to content

Conversation

@Niels-b
Copy link

@Niels-b Niels-b commented Nov 13, 2025

Updated contract API to allow only a single contract file. Includes preparatory changes to publish API.

Tried to cover as much from the CLI and API wrt to contract yaml files as possible. If this is too much for now, or not fully complete. Please let me know!

@Niels-b Niels-b requested review from m1n0 and nielsn November 13, 2025 10:57
@Niels-b Niels-b marked this pull request as ready for review November 13, 2025 10:57
Copy link

@LaurenDebruyn LaurenDebruyn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Please add more information to your PR. E.g. that the API needs to be backwards compatible. It's a lot of effort to derive this from the code itself (I already created multiple comments before I noticed this :D)

  2. I would also prevent changing the existing API (e.g. renaming verify_contracts_locally to verify_contract_locally breaks backwards compatibility). Instead I would mark it as deprecated (we can still raise an exception when you try to verify multiple contracts, although this breaks backwards compatibility as well), and create a new method verify_contract_locally.

  3. We should create a follow-up PR where we remove the logic for multiple contracts from the rest of the code (including ContractVerificationSessionResult).

soda_cloud_file_id=response_json.get("fileId", None),
),
soda_qualified_dataset_name=contract_yaml.dataset,
dataset_id=response_json.get("datasetId", None),

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you do the same for the verify response? Or was there a specific reason why you want to get this from the checks?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good suggestion, but out of scope for this PR. We will tackle that later



def verify_contracts_locally(
def verify_contract_locally(

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Either we are backwards compatible, or we are not. But renaming the function makes it per definition not backwards compatible IMO.
My proposal would be that you keep the existing function as is and mark it as deprecated (can you easily do this in Python?). We can still raise an exception if you try to verify more than one contract at once. I would create an entirely new method for the singular flow though.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tend to agree here. Split into two methods, keeping the original signature in one, introducing new signature in the other.

The old method would then perform the additional checks (length of the contract_file_paths array should be one).

Comment on lines +142 to +192
# TODO: change this when we fully deprecate a list of contract file paths
# This is only here to make sure the rest of the code still works.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you planning a follow-up PR for this? I wouldn't keep this code around for too long because we don't use multiple contracts anymore.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed, technically we don't support lists anymore. You could do the inverse here:

        if isinstance(contract_file_path, list):
            contract_file_path = contract_file_path[0]
        else:
            contract_file_path = None

Doesn't have to part of this PR, but ideally soon-ish, as we will forget about this :-)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not in scope for now. But I agree that this should definitely be done!

Comment on lines +142 to +192
# TODO: change this when we fully deprecate a list of contract file paths
# This is only here to make sure the rest of the code still works.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed, technically we don't support lists anymore. You could do the inverse here:

        if isinstance(contract_file_path, list):
            contract_file_path = contract_file_path[0]
        else:
            contract_file_path = None

Doesn't have to part of this PR, but ideally soon-ish, as we will forget about this :-)

@Niels-b Niels-b force-pushed the r-410-expose-cli-publish-command-and-return-dataset-id branch from debf0e7 to cd35de0 Compare November 14, 2025 16:10
@Niels-b
Copy link
Author

Niels-b commented Nov 14, 2025

Note: before merging still check the publish flow with new BE changes!

@sonarqubecloud
Copy link

@Niels-b
Copy link
Author

Niels-b commented Nov 17, 2025

Update: testing revealed that the dataset_id was not parsed correctly from the response. The latest commit fixes that.
PR should be ready now.

Copy link

@LaurenDebruyn LaurenDebruyn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good work!
I've added a few NITs for readability, but the overall code looks much better now :)

type=str,
nargs="+",
help="One or more contract file paths. Use this to work with local contracts.",
help="One contract file path. Use this to work with local contracts.",

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NIT: I wouldn't emphasize the one

Suggested change
help="One contract file path. Use this to work with local contracts.",
help="Contract file path to verify. Use this to work with local contracts.",

def _setup_contract_publish_command(contract_parsers) -> None:
publish_parser = contract_parsers.add_parser("publish", help="Publish a contract")
publish_parser.add_argument("-c", "--contract", type=str, nargs="+", help="One or more contract file paths.")
publish_parser.add_argument("-c", "--contract", type=str, help="One contract file path.")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here

Suggested change
publish_parser.add_argument("-c", "--contract", type=str, help="One contract file path.")
publish_parser.add_argument("-c", "--contract", type=str, help="Contract file path to verify.")

check_paths: Optional[list[str]] = None,
dwh_data_source_file_path: Optional[str] = None,
) -> ContractVerificationSessionResult:
if not isinstance(contract_file_paths, list):

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NIT: I would check for str instead of list to make it easier to read:

Suggested change
if not isinstance(contract_file_paths, list):
if isinstance(contract_file_paths, str):

verbose: bool = False,
blocking_timeout_in_minutes: int = 60,
) -> ContractVerificationSessionResult:
if not isinstance(contract_file_paths, list):

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same remark here:

Suggested change
if not isinstance(contract_file_paths, list):
if isinstance(contract_file_paths, str):

Comment on lines +191 to +196
# TODO: change this when we fully deprecate a list of contract file paths
# This is only here to make sure the rest of the code still works.
if isinstance(contract_file_path, str):
contract_file_paths = [contract_file_path]
else:
contract_file_paths = None

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NIT: move this up next to the dataset_identifier backwards compatibility code block so that we have these workarounds nicely grouped together.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants