Skip to content

Cli update#1666

Open
optk2k wants to merge 10 commits into
deeppavlov:devfrom
optk2k:cli_update
Open

Cli update#1666
optk2k wants to merge 10 commits into
deeppavlov:devfrom
optk2k:cli_update

Conversation

@optk2k
Copy link
Copy Markdown
Contributor

@optk2k optk2k commented Oct 26, 2023

  • processing exit from repl with ctrl-c and ctrl-d
  • processing typing whitespace

issue #1667

Comment thread .gitignore
log = getLogger(__name__)


def build_model(config: Union[str, Path, dict], mode: str = 'infer',
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Revert unnecessary style changes here and below. If using black (I guess), we should use it on whole code base.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

UPD: make black line lenght 120, and commit black config

Comment thread deeppavlov/core/commands/infer.py Outdated
pred = zip(*pred)

print('>>', *pred)
print("==> ", *pred)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Why? I would understand >>> like in python, but where from ==>?

Comment thread deeppavlov/core/commands/infer.py Outdated
Comment thread deeppavlov/core/commands/infer.py Outdated

print("\nExit repl - type q and press enter, or press ctrl-c, or ctrl-d.")

def input_data(prompt: str) -> tuple[str]:
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

TypeError: 'type' object is not subscriptable in Python <=3.8. Replace with typing.Tuple, add test of interact mode to tests/test_quick_start.py for one single model.

Comment thread deeppavlov/core/commands/infer.py Outdated
"""Start interaction with the model described in corresponding configuration file."""
model = build_model(config)

print("\nExit repl - type q and press enter, or press ctrl-c, or ctrl-d.")
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Suggested change
print("\nExit repl - type q and press enter, or press ctrl-c, or ctrl-d.")
print("\nExit repl - type q and press Enter, or press Ctrl-C, or Ctrl-D.")

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Replace repl with something more understandable for regular user. What other app usually write?

Comment thread deeppavlov/core/commands/infer.py Outdated


def end_repl_mode(function: Callable[..., Any]) -> Callable[..., Any]:
"""Decorator for processing ctrl-c, ctrl-d pressing."""
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Suggested change
"""Decorator for processing ctrl-c, ctrl-d pressing."""
"""Decorator for processing Ctrl-C, Ctrl-D pressing."""

Comment thread deeppavlov/core/commands/infer.py Outdated
Comment on lines +106 to +109
if data == "":
continue
if data.isspace():
continue
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Remove continue. We should allow user to remain some arguments blank.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

After removing continue, code from input_data could be moved from separated function back

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.

2 participants