-
Notifications
You must be signed in to change notification settings - Fork 4
Fix/recipe duplicates last line of csv apis #64
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
Open
alexbourret
wants to merge
8
commits into
feature/sniffing-csv-dialect
Choose a base branch
from
fix/recipe-duplicates-last-line-of-csv-apis
base: feature/sniffing-csv-dialect
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+23
−8
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
aaf4cf9
fixing last line duplication in csv apis via recipe
alexbourret ad19d07
changelog update
alexbourret 3996901
dumping in text mode as last resort
alexbourret 1a4d9fc
beta2
alexbourret 5dc9987
removing json assertion, dumping response if json.dumps fails
alexbourret c1e81b0
refacto
alexbourret 7bc0c49
changelog update
alexbourret 98d8ccd
simplify
alexbourret File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,7 @@ | ||
| from dataikuapi.utils import DataikuException | ||
| from rest_api_client import RestAPIClient | ||
| from safe_logger import SafeLogger | ||
| from dku_utils import parse_keys_for_json, get_value_from_path, decode_csv_data, de_NaN | ||
| from dku_utils import parse_keys_for_json, get_value_from_path, decode_csv_data, de_NaN, decode_bytes | ||
| from dku_constants import DKUConstants | ||
| import copy | ||
| import json | ||
|
|
@@ -111,9 +111,14 @@ def retrieve_next_page(self, is_raw_output): | |
| if is_error_message(json_response): | ||
| base_row.update(parse_keys_for_json(json_response)) | ||
| else: | ||
| base_row.update({ | ||
| DKUConstants.API_RESPONSE_KEY: json.dumps(json_response) | ||
| }) | ||
| try: | ||
| base_row.update({ | ||
| DKUConstants.API_RESPONSE_KEY: json.dumps(json_response) | ||
| }) | ||
| except Exception: | ||
| base_row.update({ | ||
| DKUConstants.API_RESPONSE_KEY: decode_bytes(json_response) | ||
| }) | ||
| else: | ||
| if isinstance(json_response, dict): | ||
| base_row.update(parse_keys_for_json(json_response)) | ||
|
|
@@ -125,8 +130,16 @@ def retrieve_next_page(self, is_raw_output): | |
| base_row.update(self.initial_parameter_columns) | ||
| page_rows.append(base_row) | ||
| else: | ||
| json_response = decode_csv_data(json_response) | ||
| for row in json_response: | ||
| decoded_csv_data = decode_csv_data(json_response) | ||
| is_api_returning_dict = False | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This breaks compatibility too but I believe this whole functionnality was introduced in an alpha for a client so probably not problematic |
||
| if not decoded_csv_data and json_response: | ||
| logger.warning("Data is not in CSV format. Dumping it in text mode.") | ||
| decoded_csv_data = [ | ||
| { | ||
| DKUConstants.API_RESPONSE_KEY: decode_bytes(json_response) | ||
| } | ||
|
RoyTeddy marked this conversation as resolved.
|
||
| ] | ||
| for row in decoded_csv_data: | ||
| base_row = copy.deepcopy(metadata) | ||
| base_row.update(parse_keys_for_json(row)) | ||
| base_row.update(self.initial_parameter_columns) | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.