Skip to content

Commit

Permalink
Merge pull request #32 from ComplexData-MILA/dtdg
Browse files Browse the repository at this point in the history
update the download logic
  • Loading branch information
shenyangHuang authored Feb 15, 2024
2 parents b17e605 + d079f19 commit a734d7f
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 5 deletions.
32 changes: 30 additions & 2 deletions py_tgx.egg-info/PKG-INFO
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,17 @@ Requires-Python: >=3.6
Description-Content-Type: text/markdown
License-File: LICENSE

# Temporal Graph Analysis with TGX (to appear in WSDM 2024)


### Example Usage ###
TGX provides many built in datasets as well as supporting TGB datasets. In addition, TGX provides dataset discretization and visualization.
To get started, see our [starting example](https://github.com/ComplexData-MILA/TGX/blob/master/starting_example.py)
```
python starting_example.py -d tgbl-wiki -t daily
```


### Install dependency
Our implementation works with python >= 3.9 and can be installed as follows

Expand All @@ -27,10 +38,27 @@ source ~/tgx_env/bin/activate
pip install -r requirements.txt
```


3. install local dependencies under root directory `/TGX`
```
<!-- ```
pip install -e py-tgx
``` -->
```
pip install -e .
```



3. [alternatively] install from test-pypi

```
pip install -i https://test.pypi.org/simple/ py-tgx
```
You can specify the version with `==`, note that the pypi version might not always be the most updated version


4. [optional] install mkdocs dependencies to serve the documentation locally
```
pip install mkdocs-glightbox
```

### Creating new branch ###
Expand Down
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
requests>=2.28.2
appdirs==1.4.4
args==0.1.0
certifi==2022.12.7
Expand Down Expand Up @@ -60,4 +61,4 @@ tzdata==2023.3
urllib3==1.26.15
virtualenv==20.0.18
wandb==0.16.3
zipp==3.15.0
zipp==3.15.0
19 changes: 17 additions & 2 deletions tgx/data/builtin.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
import pandas as pd
import zipfile
import urllib
import requests


__all__ = ["data"]

root_path = "."


DataPath={
'USLegis' : "/data/USLegis/ml_USLegis.csv",
'CanParl' : "/data/CanParl/ml_CanParl.csv",
Expand Down Expand Up @@ -36,6 +39,18 @@
'lastfm' : {'discretize' : True, 'time_scale': 'monthly'}
}

def download(url: str, output_path: str):
get_response = requests.get(url,stream=True)
file_name = url.split("/")[-1]
fpath = output_path + file_name
with open(output_path + file_name, 'wb') as f:
for chunk in get_response.iter_content(chunk_size=1024):
if chunk: # filter out keep-alive new chunks
f.write(chunk)
return fpath



class builtin(object):
def __init__(self):
"""
Expand Down Expand Up @@ -85,8 +100,8 @@ def download_file(self):
print(path_download)
print(url)
if inp == 'y':
print(f"Download started, this might take a while . . .")
zip_path, _ = urllib.request.urlretrieve(url)
print(f"Downloading {self.name} dataset . . .")
zip_path = download(url, path_download)
with zipfile.ZipFile(zip_path, "r") as f:
f.extractall(path_download)
print("Download completed")
Expand Down

0 comments on commit a734d7f

Please sign in to comment.