def upload_stream(stream, server, account, projname, language=None,<EOL>username=None, password=None,<EOL>append=False, stage=False):
client = LuminosoClient.connect(server,<EOL>username=username, password=password)<EOL>if not append:<EOL><INDENT>info = client.post('<STR_LIT>' + account, name=projname)<EOL>project_id = info['<STR_LIT>']<EOL>print('<STR_LIT>', project_id)<EOL><DEDENT>else:<EOL><INDENT>projects = client.get('<STR_LIT>' + account, name=projname)<EOL>if len(projects) == <NUM_LIT:0>:<EOL><INDENT>print('<STR_LIT>')<EOL>return<EOL><DEDENT>if len(projects) > <NUM_LIT:1>:<EOL><INDENT>print('<STR_LIT>' % projname,<EOL>end='<STR_LIT>')<EOL><DEDENT>project_id = projects[<NUM_LIT:0>]['<STR_LIT>']<EOL>print('<STR_LIT>' % project_id)<EOL><DEDENT>project = client.change_path('<STR_LIT>' + account + '<STR_LIT:/>' + project_id)<EOL>counter = <NUM_LIT:0><EOL>for batch in batches(stream, <NUM_LIT:1000>):<EOL><INDENT>counter += <NUM_LIT:1><EOL>documents = list(batch)<EOL>project.upload('<STR_LIT>', documents)<EOL>print('<STR_LIT>' % (counter))<EOL><DEDENT>if not stage:<EOL><INDENT>print('<STR_LIT>')<EOL>kwargs = {}<EOL>if language is not None:<EOL><INDENT>kwargs = {'<STR_LIT>': language}<EOL><DEDENT>job_id = project.post('<STR_LIT>', **kwargs)<EOL>project.wait_for(job_id)<EOL><DEDENT>
Given a file-like object containing a JSON stream, upload it to
Luminoso with the given account name and project name.