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
[hailctl] Autocomplete for hailctl config {get,set,unset} #13224
Merged
Merged
Changes from 14 commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
9c5ba6a
[hailctl] Autocomplete for hailctl config {get,set,unset}
jigold 4b52384
remove dev variables
jigold 4fe5344
fix and delint
jigold aeafa3a
fix
jigold 3519c8b
address comments
jigold 0253559
add documentation to install
jigold 6b86e8c
delint
jigold a20bf83
massive refactoring
jigold d82ba75
wip
jigold 300bcfd
tests
jigold 6f9bc54
tests
jigold caaec40
fixes
jigold 7cc8ee3
address comments
jigold 47104d4
fix
jigold 1fb3892
address comment
jigold 356b747
fix
jigold f11f1ea
fix
jigold 1053098
fix
jigold 77a4522
fix
jigold 25996f3
fixes
jigold 9f2f1ab
delint
jigold 77e1dff
more fixes
jigold File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
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
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,12 +1,15 @@ | ||
from .user_config import (get_user_config, get_user_config_path, | ||
get_remote_tmpdir, configuration_of) | ||
from .deploy_config import get_deploy_config, DeployConfig | ||
from .variables import ConfigVariable, config_variables | ||
|
||
__all__ = [ | ||
'get_deploy_config', | ||
'get_user_config', | ||
'get_user_config_path', | ||
'get_remote_tmpdir', | ||
'DeployConfig', | ||
'configuration_of' | ||
'ConfigVariable', | ||
'configuration_of', | ||
'config_variables', | ||
] |
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 |
---|---|---|
@@ -0,0 +1,144 @@ | ||
from collections import namedtuple | ||
from enum import Enum | ||
import re | ||
|
||
|
||
_config_variables = None | ||
|
||
ConfigVariableInfo = namedtuple('ConfigVariable', ['section', 'option', 'help_msg', 'validation']) | ||
|
||
|
||
class ConfigVariable(str, Enum): | ||
DOMAIN = 'domain' | ||
GCS_REQUESTER_PAYS_PROJECT = 'gcs_requester_pays/project', | ||
GCS_REQUESTER_PAYS_BUCKETS = 'gcs_requester_pays/buckets', | ||
BATCH_BUCKET = 'batch/bucket' | ||
BATCH_REMOTE_TMPDIR = 'batch/remote_tmpdir' | ||
BATCH_REGIONS = 'batch/regions', | ||
BATCH_BILLING_PROJECT = 'batch/billing_project' | ||
BATCH_BACKEND = 'batch/backend' | ||
QUERY_BACKEND = 'query/backend' | ||
QUERY_JAR_URL = 'query/jar_url' | ||
QUERY_BATCH_DRIVER_CORES = 'query/batch_driver_cores' | ||
QUERY_BATCH_WORKER_CORES = 'query/batch_worker_cores' | ||
QUERY_BATCH_DRIVER_MEMORY = 'query/batch_driver_memory' | ||
QUERY_BATCH_WORKER_MEMORY = 'query/batch_worker_memory' | ||
QUERY_NAME_PREFIX = 'query/name_prefix' | ||
QUERY_DISABLE_PROGRESS_BAR = 'query/disable_progress_bar' | ||
|
||
|
||
def config_variables(): | ||
from hailtop.batch_client.parse import CPU_REGEXPAT, MEMORY_REGEXPAT # pylint: disable=import-outside-toplevel | ||
from hailtop.fs.router_fs import RouterAsyncFS # pylint: disable=import-outside-toplevel | ||
|
||
global _config_variables | ||
|
||
if _config_variables is None: | ||
_config_variables = { | ||
ConfigVariable.DOMAIN: ConfigVariableInfo( | ||
section='global', | ||
option='domain', | ||
help_msg='Domain of the Batch service', | ||
validation=(lambda x: re.fullmatch(r'.+\..+', x) is not None, 'should be valid domain'), | ||
), | ||
ConfigVariable.GCS_REQUESTER_PAYS_PROJECT: ConfigVariableInfo( | ||
section='gcs_requester_pays', | ||
option='project', | ||
help_msg='Project when using requester pays buckets in GCS', | ||
validation=(lambda x: re.fullmatch(r'[^:/\s]+', x) is not None, 'should be valid GCS project name'), | ||
), | ||
ConfigVariable.GCS_REQUESTER_PAYS_BUCKETS: ConfigVariableInfo( | ||
section='gcs_requester_pays', | ||
option='buckets', | ||
help_msg='Allowed buckets when using requester pays in GCS', | ||
validation=( | ||
lambda x: re.fullmatch(r'[^:/\s]+(,[^:/\s]+)*', x) is not None, | ||
'should be comma separated list of bucket names'), | ||
), | ||
ConfigVariable.BATCH_BUCKET: ConfigVariableInfo( | ||
section='batch', | ||
option='bucket', | ||
help_msg='Deprecated - Name of GCS bucket to use as a temporary scratch directory', | ||
validation=(lambda x: re.fullmatch(r'[^:/\s]+', x) is not None, | ||
'should be valid Google Bucket identifier, with no gs:// prefix'), | ||
), | ||
ConfigVariable.BATCH_REMOTE_TMPDIR: ConfigVariableInfo( | ||
section='batch', | ||
option='remote_tmpdir', | ||
help_msg='Cloud storage URI to use as a temporary scratch directory', | ||
validation=(RouterAsyncFS.valid_url, 'should be valid cloud storage URI such as gs://my-bucket/batch-tmp/'), | ||
), | ||
ConfigVariable.BATCH_REGIONS: ConfigVariableInfo( | ||
section='batch', | ||
option='regions', | ||
help_msg='Comma-separated list of regions to run jobs in', | ||
validation=( | ||
lambda x: re.fullmatch(r'[^\s]+(,[^\s]+)*', x) is not None, 'should be comma separated list of regions'), | ||
), | ||
ConfigVariable.BATCH_BILLING_PROJECT: ConfigVariableInfo( | ||
section='batch', | ||
option='billing_project', | ||
help_msg='Batch billing project', | ||
validation=(lambda x: re.fullmatch(r'[^:/\s]+', x) is not None, 'should be valid Batch billing project name'), | ||
), | ||
ConfigVariable.BATCH_BACKEND: ConfigVariableInfo( | ||
section='batch', | ||
option='backend', | ||
help_msg='Backend to use. One of local or service.', | ||
validation=(lambda x: x in ('local', 'service'), 'should be one of "local" or "service"'), | ||
), | ||
ConfigVariable.QUERY_BACKEND: ConfigVariableInfo( | ||
section='query', | ||
option='backend', | ||
help_msg='Backend to use for Hail Query. One of spark, local, batch.', | ||
validation=(lambda x: x in ('local', 'spark', 'batch'), 'should be one of "local", "spark", or "batch"'), | ||
), | ||
ConfigVariable.QUERY_JAR_URL: ConfigVariableInfo( | ||
section='query', | ||
option='jar_url', | ||
help_msg='Cloud storage URI to a Query JAR', | ||
validation=(RouterAsyncFS.valid_url, 'should be valid cloud storage URI such as gs://my-bucket/jars/sha.jar') | ||
), | ||
ConfigVariable.QUERY_BATCH_DRIVER_CORES: ConfigVariableInfo( | ||
section='query', | ||
option='batch_driver_cores', | ||
help_msg='Cores specification for the query driver', | ||
validation=(lambda x: re.fullmatch(CPU_REGEXPAT, x) is not None, | ||
'should be an integer which is a power of two from 1 to 16 inclusive'), | ||
), | ||
ConfigVariable.QUERY_BATCH_WORKER_CORES: ConfigVariableInfo( | ||
section='query', | ||
option='batch_worker_cores', | ||
help_msg='Cores specification for the query worker', | ||
validation=(lambda x: re.fullmatch(CPU_REGEXPAT, x) is not None, | ||
'should be an integer which is a power of two from 1 to 16 inclusive'), | ||
), | ||
ConfigVariable.QUERY_BATCH_DRIVER_MEMORY: ConfigVariableInfo( | ||
section='query', | ||
option='batch_driver_memory', | ||
help_msg='Memory specification for the query driver', | ||
validation=(lambda x: re.fullmatch(MEMORY_REGEXPAT, x) is not None or x in ('standard', 'lowmem', 'highmem'), | ||
'should be a valid string specifying memory "[+]?((?:[0-9]*[.])?[0-9]+)([KMGTP][i]?)?B?" or one of standard, lowmem, highmem'), | ||
), | ||
ConfigVariable.QUERY_BATCH_WORKER_MEMORY: ConfigVariableInfo( | ||
section='query', | ||
option='batch_worker_memory', | ||
help_msg='Memory specification for the query worker', | ||
validation=(lambda x: re.fullmatch(MEMORY_REGEXPAT, x) is not None or x in ('standard', 'lowmem', 'highmem'), | ||
'should be a valid string specifying memory "[+]?((?:[0-9]*[.])?[0-9]+)([KMGTP][i]?)?B?" or one of standard, lowmem, highmem'), | ||
), | ||
ConfigVariable.QUERY_NAME_PREFIX: ConfigVariableInfo( | ||
section='query', | ||
option='name_prefix', | ||
help_msg='Name used when displaying query progress in a progress bar', | ||
validation=(lambda x: re.fullmatch(r'[^\s]+', x) is not None, 'should be single word without spaces'), | ||
), | ||
ConfigVariable.QUERY_DISABLE_PROGRESS_BAR: ConfigVariableInfo( | ||
section='query', | ||
option='disable_progress_bar', | ||
help_msg='Disable the progress bar with a value of 1. Enable the progress bar with a value of 0', | ||
validation=(lambda x: x in ('0', '1'), 'should be a value of 0 or 1'), | ||
), | ||
} | ||
|
||
return _config_variables |
Oops, something went wrong.
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.
Instead of storing the section and option again in a map, you can do
config_variable.value.split("/")
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.
If we went with your suggestion, we'd have to have something like this. Which do you prefer?
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.
I would prefer this. If I understand correctly it would allow us to delete the repeated
section
andoption
information inconfig_variables