-
Notifications
You must be signed in to change notification settings - Fork 4
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
Refactor CLI hint code and types, more CLI hint arguments #66
Merged
Merged
Changes from 2 commits
Commits
Show all changes
30 commits
Select commit
Hold shift + click to select a range
5c04553
Give Hint class a description field and move in existing values
vinceatbluelabs 1e17cc9
Initial work towards using Hint objects for CLI generation
vinceatbluelabs de1eb43
Unratchet temporarily
vinceatbluelabs 53acc55
Lazily import JsonSchemaDocument
vinceatbluelabs 04ac539
Drop unneeded import
vinceatbluelabs 72fbb2e
Get rid of records/job/hints.py entirely
vinceatbluelabs d2852a3
Limit bootstrapping parameters
vinceatbluelabs d6a46c4
Add TypedRecordsHints type
vinceatbluelabs 4b5315b
Reflect more realistic input of raw hints
vinceatbluelabs 1be53a9
Validate hints after they come in from a user as initial hints.
vinceatbluelabs 1b1c617
Introduce non-total TypedDict of hints
vinceatbluelabs af2967e
Fix tests
vinceatbluelabs fbe802d
Fix mypy issues
vinceatbluelabs 0974b1f
flake8 fixes
vinceatbluelabs f1c51ce
Convert more hint code
vinceatbluelabs c04d857
Convert more uses of record_mover.hints
vinceatbluelabs 84d74fb
Drop BootstrappingRecordsHints
vinceatbluelabs d70fe31
Standardize on PartialRecordsHints name
vinceatbluelabs 9dd54bb
Move more code to PartialRecordsHints
vinceatbluelabs 2b32314
Convert over one more use of PartialRecordsHints
vinceatbluelabs bf075b5
flake8 fixes
vinceatbluelabs 2a987e9
Fix flake8 issues
vinceatbluelabs 1481473
Merge remote-tracking branch 'origin/master' into refactor_cli_hints
vinceatbluelabs 09a8266
Increase coverage
vinceatbluelabs e47454b
Unratchet
vinceatbluelabs 30ee0ae
Remove unused import
vinceatbluelabs 7d16295
Handle --header-row and --no_header_row correctly
vinceatbluelabs 021d008
Remove dead code
vinceatbluelabs ee1ea55
Fix flake8 issue
vinceatbluelabs 2262644
Merge remote-tracking branch 'origin/master' into refactor_cli_hints
vinceatbluelabs 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 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 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 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 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,8 +1,15 @@ | ||
"""Defines hints supported by the job config parser.""" | ||
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 the duplicative descriptions of hints that are no longer needed! |
||
from records_mover.records.delimited.hints import Hints | ||
from ...utils.json_schema import JsonParameter, JsonSchemaDocument | ||
from typing import Optional | ||
|
||
|
||
SUPPORTED_HINT_NAMES = [ | ||
'field-delimiter', 'compression', 'escape', 'quoting', 'encoding', 'header-row' | ||
] | ||
|
||
|
||
# TODO: This class isn't needed anymore if we can just provide Hint class | ||
vinceatbluelabs marked this conversation as resolved.
Show resolved
Hide resolved
|
||
class SupportedHint: | ||
"""Definition for supported hints""" | ||
|
||
|
@@ -17,50 +24,12 @@ def config_name(self) -> str: | |
return self.schema.name | ||
|
||
|
||
QUOTING_DESCRIPTION =\ | ||
('How quotes are applied to individual fields. ' | ||
'all: quote all fields. ' | ||
'minimal: quote only fields that contain ambiguous characters (the ' | ||
'delimiter, the escape character, or a line terminator). ' | ||
'default: never quote fields.') | ||
|
||
# | ||
# Note: Any expansion of these types should also be done in | ||
# records.types | ||
# | ||
SUPPORTED_HINTS = [ | ||
SupportedHint( | ||
JsonParameter('field-delimiter', | ||
JsonSchemaDocument('string', | ||
description=('Character used between fields ' | ||
'(default is comma)')), | ||
optional=True)), | ||
SupportedHint( | ||
JsonParameter('compression', | ||
JsonSchemaDocument(['string', 'null'], | ||
enum=['BZIP', 'GZIP', 'LZO', None], | ||
description='Compression type of the file.'), | ||
optional=True)), | ||
SupportedHint( | ||
JsonParameter('escape', | ||
JsonSchemaDocument(['string', 'null'], | ||
enum=['\\', None], | ||
description="Character used to escape strings"), | ||
optional=True)), | ||
SupportedHint( | ||
JsonParameter('quoting', | ||
JsonSchemaDocument(['string', 'null'], | ||
enum=['all', 'minimal', 'nonnumeric', None], | ||
description=QUOTING_DESCRIPTION), | ||
optional=True)), | ||
SupportedHint( | ||
JsonParameter('encoding', | ||
JsonSchemaDocument(['string'], | ||
enum=[ | ||
'UTF8', 'UTF16', 'UTF16LE', 'UTF16BE', | ||
'LATIN1', 'CP1252' | ||
], | ||
description="Text encoding of file"), | ||
optional=True)), | ||
JsonParameter(hint_enum.value.hint_name, | ||
hint_enum.value.json_schema_document(), | ||
optional=True)) | ||
for hint_enum in list(Hints) | ||
] | ||
|
||
SUPPORTED_HINT_LOOKUP = {hint.config_name: hint for hint in SUPPORTED_HINTS} |
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.
Let's teach the Hint type to have descriptions and be able to generate JSON schema information!