Skip to content
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

Fix curate internal quotes take 2 #1565

Merged
merged 3 commits into from
Nov 13, 2024
Merged

Conversation

joverlee521
Copy link
Contributor

@joverlee521 joverlee521 commented Aug 1, 2024

Description of proposed changes

Follow the general pattern of creating CSV-like TSVs as discussed in #1563 (comment).

We are expecting the CSV-like double quoting when there are internal quotes. If the field value is already correctly double quoted, then there should not be any additional quotes.

Related issue(s)

Resolves #1312

Checklist

  • Automated checks pass
  • Check if you need to add a changelog message
  • Check if you need to add tests
  • Check if you need to update docs

Copy link

codecov bot commented Aug 2, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 72.29%. Comparing base (96f077b) to head (3f94f3e).
Report is 5 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1565   +/-   ##
=======================================
  Coverage   72.29%   72.29%           
=======================================
  Files          79       79           
  Lines        8276     8276           
  Branches     1691     1691           
=======================================
  Hits         5983     5983           
  Misses       2008     2008           
  Partials      285      285           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@joverlee521 joverlee521 mentioned this pull request Aug 2, 2024
7 tasks
@tsibley
Copy link
Member

tsibley commented Aug 2, 2024

Let's discuss this topic more first. I'll open an issue for it.

@tsibley
Copy link
Member

tsibley commented Aug 2, 2024

#1566

@joverlee521 joverlee521 marked this pull request as draft August 5, 2024 17:09
@tsibley
Copy link
Member

tsibley commented Sep 6, 2024

Saving this here for later…

Quote in field value in CSV input.

  $ augur curate passthru --metadata <(echo 'a,b'; echo 'x,"y""z"') --output-metadata -
  a	b
  x	"y""z"

Quote in field value in NDJSON input.

  $ augur curate passthru --output-metadata - <<<'{"a":"x","b":"y\"z"}'
  a	b
  x	"y""z"

Tab in field value in NDJSON input.

  $ augur curate passthru --output-metadata - <<<'{"x":"\u0009"}'
  x
  "	"

tsibley added a commit to nextstrain/measles that referenced this pull request Sep 10, 2024
This construction reads a bit clearer and cleaner.  It's also a good
example of how to use `augur merge`.

The limitation on non-seekable streams means the rule now uses
additional transient disk space, but it typically shouldn't be an issue.
The way Augur's slow start up time impacts `augur merge` also
contributes to a longer rule execution time, but it should be negligible
in the context of the larger workflow and presumably we'll fix the slow
start up eventually.¹

The output is semantically identical but has some syntactic changes re:
quoting.  It's worth noting that the pre-existing TSV format was _not_
IANA TSV, despite it (still) being treated as such in a few places, but
was (and remains) a CSV-like TSV with some quoted fields (and some
mangled quotes², e.g. the "institution" column for accession KJ556895).
We really need to sort out our TSV formats³, but that's for a larger
project.

¹ <nextstrain/augur#1628>
² <nextstrain/augur#1565>
³ <nextstrain/augur#1566>
tsibley added a commit to nextstrain/measles that referenced this pull request Sep 10, 2024
This construction reads a bit clearer and cleaner.  It's also a good
example of how to use `augur merge`.

The limitation on non-seekable streams means the workflow now uses
additional transient disk space, but it typically shouldn't be an issue.
The way Augur's slow start up time impacts `augur merge` also
contributes to a longer rule execution time, but it should be negligible
in the context of the larger workflow and presumably we'll fix the slow
start up eventually.¹

The output is semantically identical but has some syntactic changes re:
quoting.  It's worth noting that the pre-existing TSV format was _not_
IANA TSV, despite it (still) being treated as such in a few places, but
was (and remains) a CSV-like TSV with some quoted fields (and some
mangled quotes², e.g. the "institution" column for accession KJ556895).
We really need to sort out our TSV formats³, but that's for a larger
project.

¹ <nextstrain/augur#1628>
² <nextstrain/augur#1565>
³ <nextstrain/augur#1566>
@joverlee521 joverlee521 marked this pull request as ready for review October 2, 2024 22:50
@joverlee521
Copy link
Contributor Author

I think this PR should be ready for review based on #1566 (comment).

Copy link
Member

@tsibley tsibley left a comment

Choose a reason for hiding this comment

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

+1 from me for the code. This will want a good changelog entry. We might also want to test its effects on a few existing ingest pipelines?

tsibley added a commit to nextstrain/pathogen-repo-guide that referenced this pull request Oct 3, 2024
This construction reads a bit clearer and cleaner.  It's also a good
example of how to use `augur merge`.

The limitation on non-seekable streams means the workflow now uses
additional transient disk space, but it typically shouldn't be an issue.
The way Augur's slow start up time impacts `augur merge` also
contributes to a longer rule execution time, but it should be negligible
in the context of the larger workflow and presumably we'll fix the slow
start up eventually.¹

The output is semantically identical but has some syntactic changes re:
quoting.  It's worth noting that the pre-existing TSV format was _not_
IANA TSV, despite it (still) being treated as such in a few places, but
was (and remains) a CSV-like TSV with some quoted fields.  We really
need to sort out our TSV formats³, but that's for a larger project.

¹ <nextstrain/augur#1628>
² <nextstrain/augur#1565>
³ <nextstrain/augur#1566>

Ported-from: <nextstrain/measles@4d73b7f>
Related-to: <nextstrain/measles#52>
Related-to: <#65>
augur/io/metadata.py Outdated Show resolved Hide resolved
@corneliusroemer
Copy link
Member

Reminder that this is approved and apparently just waiting for changelog and merge :)

This reverts commit 915672e.

Per discussion in <#1563 (comment)>,
keep CSV-like TSV where quotes may be added or removed, but parsed
values should be equivalent.
Resolves <#1312>

We are expecting the CSV-like double quoting when there are internal
quotes. If the field value is already correctly double quoted, then
there should not be any additional quotes.
@joverlee521
Copy link
Contributor Author

Thanks for the ping @corneliusroemer! I've rebased onto master and added a Changelog entry. I'll merge once all the tests pass again.

@joverlee521 joverlee521 merged commit 4b5ad2a into master Nov 13, 2024
29 checks passed
@joverlee521 joverlee521 deleted the curate-internal-quotes branch November 13, 2024 00:47
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.

augur curate passthru can add double quotations
4 participants