-
Notifications
You must be signed in to change notification settings - Fork 0
Bug in result collector #60
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
Merged
Merged
Changes from 6 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
9f9f328
add failling test
heidi-holm-4ss 6f70307
add another failing test
heidi-holm-4ss efebb91
typo in last test
heidi-holm-4ss 36a7b0b
update push and pull to use consistent encoding
heidi-holm-4ss 575bc70
Update tests/test_core.py
heidi-holm-4ss e595a03
rename test
heidi-holm-4ss 6a21fb9
Add tox to dev dependencies
bjorn-einar-bjartnes-4ss 55f5257
Remove commented line
bjorn-einar-bjartnes-4ss 3811f14
How to install deps and run tests without tox
bjorn-einar-bjartnes-4ss d7ea2ff
Avoid rebuilding with pip commands
bjorn-einar-bjartnes-4ss 53ed216
Try to run tests on CI with only encoding set
bjorn-einar-bjartnes-4ss 61e411e
Add return back, not correct fix
bjorn-einar-bjartnes-4ss da6ce9b
Need to fix the truncation logic mixing bytes and chars
bjorn-einar-bjartnes-4ss a66db8f
Flushing and getting current pos to truncate
branislavjenco c7cf69a
Black formatting
branislavjenco 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -143,11 +143,16 @@ def __repr__(self): | |
| return f"LocalFileHandler {self._path.resolve()}" | ||
|
|
||
| def _pull(self): | ||
| return self.write(open(self._path, mode="r").read()) | ||
| # return self.write(open(self._path, mode="r", encoding=self.encoding).read()) | ||
|
heidi-holm-4ss marked this conversation as resolved.
Outdated
bjorn-einar-bjartnes-4ss marked this conversation as resolved.
Outdated
|
||
| with open(self._path, mode="r", encoding=self.encoding) as f: | ||
| content = f.read() | ||
| self.seek(0) | ||
| self.truncate(0) | ||
| self.write(content) | ||
|
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 is where the return was lost |
||
|
|
||
| def _push(self): | ||
| self._path.parent.mkdir(parents=True, exist_ok=True) | ||
| with open(self._path, mode="w") as f: | ||
| with open(self._path, mode="w", encoding=self.encoding) as f: | ||
| f.write(self.getvalue()) | ||
|
|
||
|
|
||
|
|
@@ -343,6 +348,7 @@ def __init__(self, headers, handler=None, indexing_mode="auto"): | |
| raise ValueError("Indexing mode must be 'auto' or 'timestamp'.") | ||
|
|
||
| self._dataframe = pd.DataFrame(columns=headers.keys()).astype(self._headers) | ||
| self.encoding = getattr(self._handler, "encoding", "utf-8") | ||
|
|
||
| def __repr__(self): | ||
| return repr(self._dataframe) | ||
|
|
@@ -470,6 +476,7 @@ def pull(self, raise_on_missing=True, strict=True): | |
| parse_dates=True, | ||
| dtype=self._headers, | ||
| date_format="ISO8601", | ||
| encoding=self.encoding, | ||
| ) | ||
|
|
||
| if strict and set(df_source.columns) != set(self._headers.keys()): | ||
|
|
@@ -501,11 +508,19 @@ def push(self): | |
| self._handler.truncate() | ||
| try: | ||
| self._dataframe.to_csv( | ||
| self._handler, sep=",", index=True, lineterminator="\n" | ||
| self._handler, | ||
| sep=",", | ||
| index=True, | ||
| lineterminator="\n", | ||
| encoding=self.encoding, | ||
| ) | ||
| except TypeError: # for backward compatibility (remove after 2024-06-01) | ||
| self._dataframe.to_csv( | ||
| self._handler, sep=",", index=True, line_terminator="\n" | ||
| self._handler, | ||
| sep=",", | ||
| index=True, | ||
| line_terminator="\n", | ||
| encoding=self.encoding, | ||
| ) | ||
| self._handler.push() | ||
|
|
||
|
|
||
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 |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| ,OrganizationName,timestamp,timestamp_end,dcount_ExternalId,serviceAccount | ||
| 851,Vår Energi,2025-12-01 00:00:00+00:00,2025-12-31 00:00:00+00:00,1,False | ||
| 855,Subsea 7,2025-12-01 00:00:00+00:00,2025-12-31 00:00:00+00:00,7,False | ||
| 873,Subsea 7,2025-12-01 00:00:00+00:00,2025-12-31 00:00:00+00:00,7,False | ||
| 874,Vår Energi,2025-12-01 00:00:00+00:00,2025-12-31 00:00:00+00:00,1,False | ||
| 879,4Subsea,2026-01-01 00:00:00+00:00,2026-01-31 00:00:00+00:00,1,False | ||
| 880,Unknown,2026-01-01 00:00:00+00:00,2026-01-31 00:00:00+00:00,1, |
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 |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| ,OrganizationName,timestamp,timestamp_end,dcount_ExternalId,serviceAccount | ||
| 851,Vår Energi,2025-12-01 00:00:00+00:00,2025-12-31 00:00:00+00:00,1,False | ||
| 855,Subsea 7,2025-12-01 00:00:00+00:00,2025-12-31 00:00:00+00:00,7,False | ||
| 873,Subsea 7,2025-12-01 00:00:00+00:00,2025-12-31 00:00:00+00:00,7,False | ||
| 874,Vår Energi,2025-12-01 00:00:00+00:00,2025-12-31 00:00:00+00:00,1,False | ||
| 879,4Subsea,2026-01-01 00:00:00+00:00,2026-01-31 00:00:00+00:00,1,False | ||
| 880,Unknown,2026-01-01 00:00:00+00:00,2026-01-31 00:00:00+00:00,1,False |
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.
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.
This return that was removed, made the truncate function in the base class truncate differently.