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

Remove git hash in __version__ #3466

Merged
merged 11 commits into from
Aug 4, 2020
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
8 changes: 4 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,14 @@ jobs:
strategy:
matrix:
python-version: [3.6, 3.7]
torch: [1.3.1, 1.5.1]
torch: [1.3.1, 1.5.1+cu101]
include:
- torch: 1.3.1
torchvision: 0.4.2
mmcv: "latest+torch1.3.0+cu101"
cuda_arch: "6.0"
- torch: 1.5.1
torchvision: 0.6.1
- torch: 1.5.1+cu101
torchvision: 0.6.1+cu101
mmcv: "latest+torch1.5.0+cu101"
cuda_arch: "7.0"

Expand All @@ -88,7 +88,7 @@ jobs:
run: pip install Pillow==6.2.2
if: ${{matrix.torchvision < 0.5}}
- name: Install PyTorch
run: pip install torch==${{matrix.torch}} torchvision==${{matrix.torchvision}}
run: pip install torch==${{matrix.torch}} torchvision==${{matrix.torchvision}} -f https://download.pytorch.org/whl/torch_stable.html
- name: Install mmdet dependencies
run: |
pip install mmcv-full==${{matrix.mmcv}} -f https://openmmlab.oss-accelerate.aliyuncs.com/mmcv/dist/index.html
Expand Down
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ venv.bak/
# mypy
.mypy_cache/

mmdet/version.py
data/
.vscode
.idea
Expand Down
11 changes: 9 additions & 2 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,17 @@
project = 'MMDetection'
copyright = '2018-2020, OpenMMLab'
author = 'MMDetection Authors'
version_file = '../mmdet/version.py'


def get_version():
with open(version_file, 'r') as f:
exec(compile(f.read(), version_file, 'exec'))
return locals()['__version__']


# The full version, including alpha/beta/rc tags
with open('../mmdet/VERSION', 'r') as f:
release = f.read().strip()
release = get_version()

# -- General configuration ---------------------------------------------------

Expand Down
1 change: 0 additions & 1 deletion mmdet/VERSION

This file was deleted.

4 changes: 2 additions & 2 deletions mmdet/utils/collect_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import mmcv
import torch
import torchvision
from mmcv.utils import get_build_config
from mmcv.utils import get_build_config, get_git_hash

import mmdet

Expand Down Expand Up @@ -53,7 +53,7 @@ def collect_env():
env_info['OpenCV'] = cv2.__version__

env_info['MMCV'] = mmcv.__version__
env_info['MMDetection'] = mmdet.__version__
env_info['MMDetection'] = mmdet.__version__ + '+' + get_git_hash()[:7]
from mmcv.ops import get_compiler_version, get_compiling_cuda_version
env_info['MMDetection Compiler'] = get_compiler_version()
env_info['MMDetection CUDA Compiler'] = get_compiling_cuda_version()
Expand Down
19 changes: 19 additions & 0 deletions mmdet/version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Copyright (c) Open-MMLab. All rights reserved.

__version__ = '2.3.0rc0'
ZwwWayne marked this conversation as resolved.
Show resolved Hide resolved
short_version = __version__


def parse_version_info(version_str):
version_info = []
for x in version_str.split('.'):
if x.isdigit():
version_info.append(int(x))
elif x.find('rc') != -1:
patch_version = x.split('rc')
version_info.append(int(patch_version[0]))
version_info.append(f'rc{patch_version[1]}')
return tuple(version_info)


version_info = parse_version_info(__version__)
66 changes: 1 addition & 65 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
#!/usr/bin/env python
import os
import subprocess
import time
from setuptools import find_packages, setup

import torch
Expand All @@ -18,68 +16,6 @@ def readme():
version_file = 'mmdet/version.py'


def get_git_hash():

def _minimal_ext_cmd(cmd):
# construct minimal environment
env = {}
for k in ['SYSTEMROOT', 'PATH', 'HOME']:
v = os.environ.get(k)
if v is not None:
env[k] = v
# LANGUAGE is used on win32
env['LANGUAGE'] = 'C'
env['LANG'] = 'C'
env['LC_ALL'] = 'C'
out = subprocess.Popen(
cmd, stdout=subprocess.PIPE, env=env).communicate()[0]
return out

try:
out = _minimal_ext_cmd(['git', 'rev-parse', 'HEAD'])
sha = out.strip().decode('ascii')
except OSError:
sha = 'unknown'

return sha


def get_hash():
if os.path.exists('.git'):
sha = get_git_hash()[:7]
elif os.path.exists(version_file):
try:
from mmdet.version import __version__
sha = __version__.split('+')[-1]
except ImportError:
raise ImportError('Unable to get git version')
else:
sha = 'unknown'

return sha


def write_version_py():
content = """# GENERATED VERSION FILE
# TIME: {}

__version__ = '{}'
short_version = '{}'
version_info = ({})
"""
sha = get_hash()
with open('mmdet/VERSION', 'r') as f:
SHORT_VERSION = f.read().strip()
VERSION_INFO = ', '.join(
[x if x.isdigit() else f'"{x}"' for x in SHORT_VERSION.split('.')])
VERSION = SHORT_VERSION + '+' + sha

version_file_str = content.format(time.asctime(), VERSION, SHORT_VERSION,
VERSION_INFO)
with open(version_file, 'w') as f:
f.write(version_file_str)


def get_version():
with open(version_file, 'r') as f:
exec(compile(f.read(), version_file, 'exec'))
Expand Down Expand Up @@ -190,12 +126,12 @@ def gen_packages_items():


if __name__ == '__main__':
write_version_py()
setup(
name='mmdet',
version=get_version(),
description='OpenMMLab Detection Toolbox and Benchmark',
long_description=readme(),
long_description_content_type='text/markdown',
author='OpenMMLab',
author_email='openmmlab@gmail.com',
keywords='computer vision, object detection',
Expand Down
3 changes: 2 additions & 1 deletion tools/train.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import torch
from mmcv import Config, DictAction
from mmcv.runner import init_dist
from mmcv.utils import get_git_hash

from mmdet import __version__
from mmdet.apis import set_random_seed, train_detector
Expand Down Expand Up @@ -134,7 +135,7 @@ def main():
# save mmdet version, config file content and class names in
# checkpoints as meta data
cfg.checkpoint_config.meta = dict(
mmdet_version=__version__,
mmdet_version=__version__ + get_git_hash()[:7],
config=cfg.pretty_text,
CLASSES=datasets[0].CLASSES)
# add an attribute for visualization convenience
Expand Down