Unverified Commit 267f4bc0 authored by Farhad Ramezanghorbani's avatar Farhad Ramezanghorbani Committed by GitHub
Browse files

Include model parameter placeholders in site-packages (#500)

* skip downloading into site-packages

* add placeholder files

* add placeholder files

* dont check filesize in local_dir

* fix shutil erro

* use distutils instead of shutils
parent 42442af6
...@@ -30,9 +30,6 @@ dist ...@@ -30,9 +30,6 @@ dist
*.swo *.swo
/download /download
/download.tar.xz /download.tar.xz
/torchani/resources/*.info
/torchani/resources/ani-1ccx_8x
/torchani/resources/ani-2x_8x
*.qdrep *.qdrep
*.qdstrm *.qdstrm
*.zip *.zip
......
...@@ -31,10 +31,9 @@ directly calculate energies or get an ASE calculator. For example: ...@@ -31,10 +31,9 @@ directly calculate energies or get an ASE calculator. For example:
import os import os
import io import io
import requests import requests
import glob
import zipfile import zipfile
import shutil
import torch import torch
from distutils import dir_util
from torch import Tensor from torch import Tensor
from typing import Tuple, Optional from typing import Tuple, Optional
from . import neurochem from . import neurochem
...@@ -89,7 +88,7 @@ class BuiltinModel(torch.nn.Module): ...@@ -89,7 +88,7 @@ class BuiltinModel(torch.nn.Module):
extracted_name = '{}-{}'.format(repo_name, tag_name) extracted_name = '{}-{}'.format(repo_name, tag_name)
url = "https://github.com/aiqm/{}/archive/{}.zip".format(repo_name, tag_name) url = "https://github.com/aiqm/{}/archive/{}.zip".format(repo_name, tag_name)
if not os.path.isfile(get_resource(resource_path, info_file_path)): if os.stat(get_resource(resource_path, info_file_path)).st_size == 0:
if not os.path.isfile(get_resource(local_dir, info_file_path)): if not os.path.isfile(get_resource(local_dir, info_file_path)):
print('Downloading ANI model parameters ...') print('Downloading ANI model parameters ...')
resource_res = requests.get(url) resource_res = requests.get(url)
...@@ -99,17 +98,14 @@ class BuiltinModel(torch.nn.Module): ...@@ -99,17 +98,14 @@ class BuiltinModel(torch.nn.Module):
except PermissionError: except PermissionError:
resource_zip.extractall(local_dir) resource_zip.extractall(local_dir)
resource_path = local_dir resource_path = local_dir
source = os.path.join(resource_path, extracted_name, "resources")
dir_util.copy_tree(source, resource_path)
dir_util.remove_tree(os.path.join(resource_path, extracted_name))
else: else:
resource_path = local_dir resource_path = local_dir
files = glob.glob(os.path.join(resource_path, extracted_name, "resources", "*"))
for f in files:
try:
shutil.move(f, resource_path)
except shutil.Error:
pass
shutil.rmtree(os.path.join(resource_path, extracted_name))
info_file = get_resource(resource_path, info_file_path) info_file = get_resource(resource_path, info_file_path)
with open(info_file) as f: with open(info_file) as f:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment