23 lines
1.5 KiB
Python
23 lines
1.5 KiB
Python
import pathlib,json,sys,shutil,os,datetime
|
|
sys.path.insert(0,'/home/ps/huobao-gpu-selection')
|
|
from docker_worker_ops import api,inspect,replace_bind,write_json
|
|
root=pathlib.Path('/home/ps/huobao-gpu-selection/gpu3-vdn');name='h3-caption-gpu3-canary-8a5f'
|
|
d=inspect(name);assert d['State']['Status']=='created','Only repair the not-started candidate'
|
|
original=json.loads((root/'source.inspect.json').read_text())
|
|
source=pathlib.Path(next(m['Source'] for m in original['Mounts'] if m['Destination']=='/app/custom_nodes'))
|
|
target=root/'custom_nodes';assert not target.exists()
|
|
def link_or_copy(src,dst):
|
|
try:os.link(src,dst)
|
|
except OSError:shutil.copy2(src,dst)
|
|
return dst
|
|
shutil.copytree(source,target,copy_function=link_or_copy,symlinks=True,ignore=shutil.ignore_patterns('__pycache__','.git'))
|
|
shutil.copytree(root/'ComfyUI-VDN-H3',target/'ComfyUI-VDN-H3')
|
|
cfg=json.loads((root/'create.json').read_text())
|
|
cfg['HostConfig']['Binds']=[b for b in cfg['HostConfig']['Binds'] if b.split(':')[1]!='/app/custom_nodes/ComfyUI-VDN-H3']
|
|
replace_bind(cfg,'/app/custom_nodes',target)
|
|
write_json(root/'create-fixed.json',cfg)
|
|
api('POST','/containers/'+name+'/rename?name='+name+'-mount-failed-'+datetime.datetime.now().strftime('%H%M%S'))
|
|
created=api('POST','/containers/create?name='+name,cfg);api('POST','/containers/'+name+'/start')
|
|
write_json(root/'fixed-created.json',created)
|
|
print('Started GPU3 with isolated complete plugin directory; shared plugin directory unchanged:',created['Id'][:12])
|