-
Notifications
You must be signed in to change notification settings - Fork 249
Updates to CLI and programatic API #2474
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: v4
Are you sure you want to change the base?
Updates to CLI and programatic API #2474
Conversation
LaurenDebruyn
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-
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)
-
I would also prevent changing the existing API (e.g. renaming
verify_contracts_locallytoverify_contract_locallybreaks 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 methodverify_contract_locally. -
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), |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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( |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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).
| # 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. |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 :-)
There was a problem hiding this comment.
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!
| # 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. |
There was a problem hiding this comment.
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 :-)
…hanges to publish API
… identifier. Exposed publish_contract to API
debf0e7 to
cd35de0
Compare
|
Note: before merging still check the publish flow with new BE changes! |
|
|
Update: testing revealed that the |
LaurenDebruyn
left a comment
There was a problem hiding this 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.", |
There was a problem hiding this comment.
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
| 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.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here
| 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): |
There was a problem hiding this comment.
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:
| 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): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same remark here:
| if not isinstance(contract_file_paths, list): | |
| if isinstance(contract_file_paths, str): |
| # 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 |
There was a problem hiding this comment.
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.



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!