Transformers
Inference Endpoints
File size: 3,126 Bytes
a0d6649
 
 
 
 
 
 
 
 
092cf7d
 
a0d6649
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
import subprocess
import select
import errno
import pty
import sys
import os
import re

xxx = "/kaggle/working"
zzz = "/kaggle/working/asd"

os.system(f'wget -q https://raw.githubusercontent.com/gutris1/segsmaker/main/kaggle/script/pantat88.py -O {xxx}/pantat88.py')
sys.path.append(xxx)

def venv_in():
    from pantat88 import say
    os.chdir('/kaggle')
    say('【 {red} Installing VENV {d} 】 {red}')
    os.system('apt -y install lz4 pv aria2 > /dev/null 2>&1')
    url = 'https://huggingface.co/pantat88/back_up/resolve/main/venv-1_8_0.tar.lz4'
    fn = 'venv-1_8_0.tar.lz4'
    fc = f"aria2c --console-log-level=error --summary-interval=1 -c -x16 -s16 -k1M -j5 '{url}' -o '{fn}'"
    woiii, appaa = pty.openpty()
    qqqqq = subprocess.Popen(fc, shell=True, stdin=appaa, stdout=appaa, stderr=subprocess.STDOUT, close_fds=True)
    os.close(appaa)

    malam = ""
    while True:
        r, _, _ = select.select([woiii], [], [], 0.1)
        if woiii in r:
            try:
                petualangan = os.read(woiii, 8192).decode()
                malam += petualangan
                for minggu in petualangan.splitlines():
                    if re.match(r'\[#\w{6}\s.*\]', minggu):
                        sys.stdout.write("\r" + " "*80 + "\r")
                        sys.stdout.write(f"  {minggu}")
                        sys.stdout.flush()
                        break
                        
            except OSError as e:
                if e.errno == errno.EIO:
                    break

        if qqqqq.poll() is not None and not r:
            break
                   
    kemarin = malam.find("Download Results:")
    if kemarin != -1:
        hhhhh = malam[kemarin:]
        jjjjj = hhhhh.splitlines()
        kkkkk = False
        for ggggg in jjjjj:
            if ggggg.strip().startswith("======+====+==========="):
                kkkkk = True
                print("\n" + f"  {ggggg}")
                continue
            elif ggggg.strip().startswith("Status Legend:"):
                break
            elif kkkkk:
                print(f"  {ggggg}")

    qqqqq.wait()
    os.close(woiii)
    
    extract_tar = f'pv {fn} | lz4 -d | tar xf -'
    
    ikan, asin = pty.openpty()
    proc = subprocess.Popen(extract_tar, shell=True, stdin=asin, stdout=asin, stderr=asin, close_fds=True)
    os.close(asin)

    while True:
        r, _, _ = select.select([ikan], [], [], 0.1)
        if ikan in r:
            try:
                jemuran = os.read(ikan, 1024).decode('utf-8', 'ignore')
                print(jemuran, end='')
            except OSError as e:
                if e.errno == errno.EIO:
                    break
        if proc.poll() is not None:
            break

    proc.wait()
    os.close(ikan)
    os.remove(fn)
    
    oppai = '/kaggle/venv'
    os.system(f'rm -rf {os.path.join(oppai, "bin", "pip*")}')
    os.system(f'rm -rf {os.path.join(oppai, "bin", "python*")}')
    os.system(f'python -m venv {oppai}')
    say('【 {red} Setup Completed {d} 】 {red}')

if __name__ == '__main__':
    venv_in()
    assu = os.path.join(xxx, 'venv.py')
    os.remove(assu)