You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I recently had to make a "pipe mode" for Argos, which can read lines from stdin and translate each line separately, as soon as a \n is received. (This is since I couldn't install argos in the virtualenvironment I had other software in, which would have let me directly call it from Python. I have too many requests to make it worth re-starting Python for each query). Is this something you'd be interested in as a pull request? I guess I'd add a --pipe option to the existing argos-translate and try to reuse the existing other options for configuration. Or I could make piping the default if no argument is given.
Thanks for Argos! It has been very useful.
Below is the synopsis of my current frontent and what I would implement:
whileTrue:
# walrus operator would be appropriate but 3.8 still too new for my tastes line=sysstdin.readline()
ifnotline:
breakifargs.format=='json':
line=json.loads(line)
new=argostranslate.translate.translate(
line, sys.argv[1], sys.argv[2])
ifargs.format=='json':
print(json.dumps(new))
sys.stdout.flush()
else:
print(new)
The text was updated successfully, but these errors were encountered:
rkdarst
changed the title
Pipe mode (stdin/stdout)
Pipe mode, line-by-line (stdin/stdout)
Feb 8, 2024
I recently had to make a "pipe mode" for Argos, which can read lines from stdin and translate each line separately, as soon as a
\n
is received. (This is since I couldn't install argos in the virtualenvironment I had other software in, which would have let me directly call it from Python. I have too many requests to make it worth re-starting Python for each query). Is this something you'd be interested in as a pull request? I guess I'd add a--pipe
option to the existingargos-translate
and try to reuse the existing other options for configuration. Or I could make piping the default if no argument is given.Thanks for Argos! It has been very useful.
Below is the synopsis of my current frontent and what I would implement:
The text was updated successfully, but these errors were encountered: