Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update setup.py: Make more requirements optional #4133

Merged
merged 7 commits into from
Feb 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions .github/workflows/install.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Minimal Installation

on: # yamllint disable-line rule:truthy
push:
branches:
- master
pull_request:

jobs:

import:
runs-on: ${{ matrix.os }}

strategy:
matrix:
os: [ubuntu-latest]
python-version: [3.9]
torch-version: [1.10.0]

steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}

- name: Install PyTorch ${{ matrix.torch-version }}+cpu
run: |
pip install torch==${{ matrix.torch-version}}+cpu -f https://download.pytorch.org/whl/torch_stable.html

- name: Install internal dependencies
run: |
pip install torch-scatter -f https://data.pyg.org/whl/torch-${{ matrix.torch-version }}+cpu.html
pip install torch-sparse -f https://data.pyg.org/whl/torch-${{ matrix.torch-version }}+cpu.html

- name: Install main package
run: |
pip install .

- name: Test imports
run: |
python -c "import torch_geometric"
python -c "import torch_geometric.datasets"
python -c "import torch_geometric.nn"
python -c "import torch_geometric.graphgym"
8 changes: 4 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,30 +5,30 @@

install_requires = [
'tqdm',
'yacs',
'numpy',
'scipy',
'pandas',
'jinja2',
'requests',
'pyparsing',
'hydra-core',
'scikit-learn',
'class-resolver>=0.3.2',
'googledrivedownloader',
]

full_install_requires = [
'h5py',
'yacs',
'numba',
'captum',
'rdflib',
'trimesh',
'networkx',
'tabulate',
'hydra-core',
'matplotlib',
'scikit-image',
'pytorch-memlab',
'class-resolver>=0.3.2',
'googledrivedownloader',
]

test_requires = [
Expand Down
14 changes: 10 additions & 4 deletions torch_geometric/graphgym/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,21 @@
import logging
import os
import shutil
import warnings
from collections.abc import Iterable
from dataclasses import asdict
from typing import Any

from yacs.config import CfgNode as CN

import torch_geometric.graphgym.register as register
from torch_geometric.data.makedirs import makedirs

# Global config object
cfg = CN()
try: # Define global config object
from yacs.config import CfgNode as CN
cfg = CN()
except ImportError:
cfg = None
warnings.warn("Could not define global config object. Please install "
"'yacs' for using the GraphGym experiment manager.")


def set_cfg(cfg):
Expand All @@ -26,6 +30,8 @@ def set_cfg(cfg):

:return: configuration use by the experiment.
'''
if cfg is None:
return cfg

# ----------------------------------------------------------------------- #
# Basic options
Expand Down
15 changes: 8 additions & 7 deletions torch_geometric/graphgym/models/act.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
from torch_geometric.graphgym.config import cfg
from torch_geometric.graphgym.register import register_act

register_act('relu', nn.ReLU(inplace=cfg.mem.inplace))
register_act('selu', nn.SELU(inplace=cfg.mem.inplace))
register_act('prelu', nn.PReLU())
register_act('elu', nn.ELU(inplace=cfg.mem.inplace))
register_act('lrelu_01', nn.LeakyReLU(0.1, inplace=cfg.mem.inplace))
register_act('lrelu_025', nn.LeakyReLU(0.25, inplace=cfg.mem.inplace))
register_act('lrelu_05', nn.LeakyReLU(0.5, inplace=cfg.mem.inplace))
if cfg is not None:
register_act('relu', nn.ReLU(inplace=cfg.mem.inplace))
register_act('selu', nn.SELU(inplace=cfg.mem.inplace))
register_act('prelu', nn.PReLU())
register_act('elu', nn.ELU(inplace=cfg.mem.inplace))
register_act('lrelu_01', nn.LeakyReLU(0.1, inplace=cfg.mem.inplace))
register_act('lrelu_025', nn.LeakyReLU(0.25, inplace=cfg.mem.inplace))
register_act('lrelu_05', nn.LeakyReLU(0.5, inplace=cfg.mem.inplace))
5 changes: 0 additions & 5 deletions torch_geometric/graphgym/models/gnn.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,3 @@ def forward(self, batch):
for module in self.children():
batch = module(batch)
return batch

if cfg.benchmark:
# register to measure the forward pass
from torch_geometric.graphgym.benchmark import global_line_profiler
global_line_profiler.add_function(forward)
4 changes: 2 additions & 2 deletions torch_geometric/graphgym/utils/comp_budget.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import math

from yacs.config import CfgNode as CN

from torch_geometric.graphgym.config import cfg, set_cfg
from torch_geometric.graphgym.model_builder import create_model

Expand Down Expand Up @@ -60,6 +58,7 @@ def match_computation(stats_baseline, key=['gnn', 'dim_inner'], mode='sqrt'):


def dict_to_stats(cfg_dict):
from yacs.config import CfgNode as CN
set_cfg(cfg)
cfg_new = CN(cfg_dict)
cfg.merge_from_other_cfg(cfg_new)
Expand All @@ -80,6 +79,7 @@ def match_baseline_cfg(cfg_dict, cfg_dict_baseline, verbose=True):


'''
from yacs.config import CfgNode as CN
stats_baseline = dict_to_stats(cfg_dict_baseline)
set_cfg(cfg)
cfg_new = CN(cfg_dict)
Expand Down