Skip to content
This repository has been archived by the owner on May 22, 2019. It is now read-only.

Commit

Permalink
Merge pull request #86 from fineguy/develop
Browse files Browse the repository at this point in the history
Add bblfsh_raise_errors flag
  • Loading branch information
vmarkovtsev authored Sep 13, 2017
2 parents afe00fb + 80f3569 commit 973707e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
15 changes: 10 additions & 5 deletions ast2vec/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def get_parser() -> argparse.ArgumentParser:
help="Number of threads in the UASTs extraction process.")

organize_files_arg = one_arg_parser(
"--organize_files", type=int, default=RepoTransformer.DEFAULT_ORGANIZE_FILES,
"--organize-files", type=int, default=RepoTransformer.DEFAULT_ORGANIZE_FILES,
help="Perform alphabetical directory indexing of provided level. Expand output path by "
"subfolders using the first n characters of repository, for example for "
"\"--organize-files 2\" file ababa is saved to /a/ab/ababa, abcoasa is saved to "
Expand All @@ -94,6 +94,11 @@ def get_parser() -> argparse.ArgumentParser:
dest="overwrite_existing",
help="Specify if you want to disable overiting of existing models")

bblfsh_raise_arg = one_arg_parser(
"--bblfsh-raise", action="store_true", default=Repo2Base.DEFAULT_BBLFSH_RAISE_ERRORS,
dest="bblfsh_raise_errors",
help="Specify if you want to raise errors upon receiving errors from bblfsh server")

linguist_arg = one_arg_parser(
"--linguist", help="Path to src-d/enry executable.")

Expand Down Expand Up @@ -162,14 +167,14 @@ def get_parser() -> argparse.ArgumentParser:

repo2uast_parser = subparsers.add_parser(
"repo2uast", help="Extract UASTs from a Git repository.",
parents=[repository_arg, linguist_arg, output_dir_arg_asdf, bblfsh_args,
process_1_2_arg, threads_arg, organize_files_arg, disable_overwrite_arg])
parents=[repository_arg, linguist_arg, output_dir_arg_asdf, bblfsh_args, process_1_2_arg,
threads_arg, organize_files_arg, disable_overwrite_arg, bblfsh_raise_arg])
repo2uast_parser.set_defaults(handler=repo2uast_entry)

repos2uast_parser = subparsers.add_parser(
"repos2uast", help="Extract UASTs from a list of Git repositories.",
parents=[repos2input_arg, linguist_arg, output_dir_arg_asdf, bblfsh_args,
process_1_2_arg, threads_arg, organize_files_arg, disable_overwrite_arg])
parents=[repos2input_arg, linguist_arg, output_dir_arg_asdf, bblfsh_args, process_1_2_arg,
threads_arg, organize_files_arg, disable_overwrite_arg, bblfsh_raise_arg])
repos2uast_parser.set_defaults(handler=repos2uast_entry)

repo2source_parser = subparsers.add_parser(
Expand Down
3 changes: 2 additions & 1 deletion ast2vec/repo2/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,13 @@ def __init__(self, tempdir=None, linguist=None, log_level=logging.INFO,
bblfsh_raise_errors=DEFAULT_BBLFSH_RAISE_ERRORS):
"""
Initializer of Repo2Base class
:param tempdir: If you will clone repositories they will be stored in tempdir
:param tempdir: If you clone repositories they will be stored in tempdir
:param linguist: Path to linguist.
:param log_level: Log level of Repo2Base
:param bblfsh_endpoint: bblfsh server endpoint
:param timeout: timeout for bblfsh
:param overwrite_existing: Rewrite existing models or skip them
:param bblfsh_raise_errors: If `True` raises errors when you get errors in bblfsh responses
"""
super(Repo2Base, self).__init__(log_level=log_level)
self.tempdir = tempdir
Expand Down

0 comments on commit 973707e

Please sign in to comment.