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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

joverlee521
Copy link
Contributor

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

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.
Copy link

codecov bot commented Aug 2, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 70.22%. Comparing base (c28fab2) to head (ad029f6).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1565   +/-   ##
=======================================
  Coverage   70.22%   70.22%           
=======================================
  Files          76       76           
  Lines        7987     7987           
  Branches     1947     1947           
=======================================
  Hits         5609     5609           
  Misses       2092     2092           
  Partials      286      286           

☔ 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>
lineterminator='\n',
quoting=csv.QUOTE_NONE,
quotechar=None,
lineterminator='\n'
Copy link
Contributor

Choose a reason for hiding this comment

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

very nit, much pick

Suggested change
lineterminator='\n'
lineterminator='\n',

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
3 participants