Skip to content

Commit 84cfb3c

Browse files
authored
Merge pull request #3 from CCInc/master
add pre-commit/gitignore
2 parents 9e1d132 + 826ca5c commit 84cfb3c

File tree

6 files changed

+203
-8
lines changed

6 files changed

+203
-8
lines changed

.gitignore

Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
# tp3d specific
2+
outputs/
3+
data/
4+
5+
# Byte-compiled / optimized / DLL files
6+
__pycache__/
7+
*.py[cod]
8+
*$py.class
9+
10+
# C extensions
11+
*.so
12+
13+
# Distribution / packaging
14+
.Python
15+
build/
16+
develop-eggs/
17+
dist/
18+
downloads/
19+
eggs/
20+
.eggs/
21+
lib/
22+
lib64/
23+
parts/
24+
sdist/
25+
var/
26+
wheels/
27+
share/python-wheels/
28+
*.egg-info/
29+
.installed.cfg
30+
*.egg
31+
MANIFEST
32+
33+
# PyInstaller
34+
# Usually these files are written by a python script from a template
35+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
36+
*.manifest
37+
*.spec
38+
39+
# Installer logs
40+
pip-log.txt
41+
pip-delete-this-directory.txt
42+
43+
# Unit test / coverage reports
44+
htmlcov/
45+
.tox/
46+
.nox/
47+
.coverage
48+
.coverage.*
49+
.cache
50+
nosetests.xml
51+
coverage.xml
52+
*.cover
53+
*.py,cover
54+
.hypothesis/
55+
.pytest_cache/
56+
cover/
57+
58+
# Translations
59+
*.mo
60+
*.pot
61+
62+
# Django stuff:
63+
*.log
64+
local_settings.py
65+
db.sqlite3
66+
db.sqlite3-journal
67+
68+
# Flask stuff:
69+
instance/
70+
.webassets-cache
71+
72+
# Scrapy stuff:
73+
.scrapy
74+
75+
# Sphinx documentation
76+
docs/_build/
77+
78+
# PyBuilder
79+
.pybuilder/
80+
target/
81+
82+
# Jupyter Notebook
83+
.ipynb_checkpoints
84+
85+
# IPython
86+
profile_default/
87+
ipython_config.py
88+
89+
# pyenv
90+
# For a library or package, you might want to ignore these files since the code is
91+
# intended to run in multiple environments; otherwise, check them in:
92+
# .python-version
93+
94+
# pipenv
95+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
96+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
97+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
98+
# install all needed dependencies.
99+
#Pipfile.lock
100+
101+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow
102+
__pypackages__/
103+
104+
# Celery stuff
105+
celerybeat-schedule
106+
celerybeat.pid
107+
108+
# SageMath parsed files
109+
*.sage.py
110+
111+
# Environments
112+
.env
113+
.venv
114+
env/
115+
venv/
116+
ENV/
117+
env.bak/
118+
venv.bak/
119+
120+
# Spyder project settings
121+
.spyderproject
122+
.spyproject
123+
124+
# Rope project settings
125+
.ropeproject
126+
127+
# mkdocs documentation
128+
/site
129+
130+
# mypy
131+
.mypy_cache/
132+
.dmypy.json
133+
dmypy.json
134+
135+
# Pyre type checker
136+
.pyre/
137+
138+
# pytype static type analyzer
139+
.pytype/
140+
141+
# Cython debug symbols
142+
cython_debug/

.pre-commit-config.yaml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
exclude: 'benchmark|conf|data|docs|outputs'
2+
3+
repos:
4+
- repo: https://github.com/pre-commit/pre-commit-hooks
5+
rev: v1.2.3
6+
hooks:
7+
- id: trailing-whitespace
8+
- id: end-of-file-fixer
9+
- id: check-added-large-files
10+
args: [--maxkb=15000]
11+
- id: check-yaml
12+
13+
- repo: https://github.com/ambv/black
14+
rev: stable
15+
hooks:
16+
- id: black
17+
language_version: python
18+
19+
- repo: https://github.com/humitos/mirrors-autoflake.git
20+
rev: v1.3
21+
hooks:
22+
- id: autoflake
23+
args:
24+
[
25+
'--in-place',
26+
'--remove-unused-variable',
27+
'--ignore-init-module-imports',
28+
'--imports=torch,torch_geometric,torch_scatter,torch_cluster,numpy,sklearn,scipy,torch_sparse,torch_points_kernels',
29+
]
30+
- repo: https://github.com/kynan/nbstripout
31+
rev: master
32+
hooks:
33+
- id: nbstripout
34+
files: '.ipynb'
35+
36+
# - repo: local
37+
# hooks:
38+
# - id: requirements.txt
39+
# name: Generate requirements.txt
40+
# entry: poetry export
41+
# args:
42+
# [
43+
# '-f',
44+
# 'requirements.txt',
45+
# '-o',
46+
# 'requirements.txt',
47+
# '--without-hashes',
48+
# ]
49+
# pass_filenames: false
50+
# language: system
51+
# files: 'poetry.lock'

pyproject.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[tool.black]
2+
line-length = 120

torch_points3d/core/instantiator.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515

1616

1717
class Instantiator:
18-
1918
def model(self, *args, **kwargs):
2019
raise NotImplementedError("Child class must implement method")
2120

@@ -39,13 +38,12 @@ def instantiate(self, *args, **kwargs):
3938

4039

4140
class HydraInstantiator(Instantiator):
42-
4341
def model(
4442
self,
4543
cfg: DictConfig,
4644
model_data_kwargs: Optional[DictConfig] = None,
4745
tokenizer: Optional[DictConfig] = None,
48-
pipeline_kwargs: Optional[DictConfig] = None
46+
pipeline_kwargs: Optional[DictConfig] = None,
4947
) -> "TaskTransformer":
5048
if model_data_kwargs is None:
5149
model_data_kwargs = {}
@@ -100,4 +98,4 @@ def trainer(self, cfg: DictConfig, **kwargs) -> pl.Trainer:
10098
return self.instantiate(cfg, **kwargs)
10199

102100
def instantiate(self, *args, **kwargs):
103-
return hydra.utils.instantiate(*args, **kwargs)
101+
return hydra.utils.instantiate(*args, **kwargs)

torch_points3d/trainer.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def instantiate_trainer(self):
2020

2121
def instantiate_dataset_and_model(self):
2222
dataset: BaseDataset = instantiate_dataset(self._cfg.data)
23-
model: BaseModel = instantiate_model(copy.deepcopy(cfg), dataset)
23+
model: BaseModel = instantiate_model(copy.deepcopy(cfg), dataset)
2424
model.instantiate_optimizers(cfg) # we will change it and instantiate the optimizers separately
2525
model.set_pretrained_weights()
2626
dataset.create_dataloaders(
@@ -34,10 +34,9 @@ def instantiate_dataset_and_model(self):
3434

3535
def train(self):
3636

37-
37+
3838
# model.tracker_options = cfg.get("tracker_options", {})
3939
# model.trackers = data_module.trackers
4040
model, data_module = self.instantiate_dataset_and_model()
4141
trainer = self.instantiate_trainer()
4242
trainer.fit(model, data_module)
43-

train.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
from omegaconf import OmegaConf
44
from torch_points3d.trainer import LitTrainer
55

6-
OmegaConf.register_new_resolver("get_filename", lambda x: x.split('/')[-1])
6+
OmegaConf.register_new_resolver("get_filename", lambda x: x.split("/")[-1])
7+
8+
79
@hydra.main(config_path="conf", config_name="config")
810
def main(cfg):
911
OmegaConf.set_struct(cfg, False) # This allows getattr and hasattr methods to function correctly
@@ -13,5 +15,6 @@ def main(cfg):
1315
trainer = LitTrainer(cfg)
1416
trainer.train()
1517

18+
1619
if __name__ == "__main__":
1720
main()

0 commit comments

Comments
 (0)