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

[AIRFLOW-144] Make enhancements to VersionView #1523

Merged
merged 1 commit into from
May 19, 2016
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
2 changes: 1 addition & 1 deletion airflow/www/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -2307,7 +2307,7 @@ def version(self):
# Get the Git repo and git hash
git_version = None
try:
with open("airflow/git_version") as f:
with open(os.path.join(*[settings.AIRFLOW_HOME, 'airflow', 'git_version'])) as f:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Curious about this. Do you guys run with AIRFLOW_HOME containing the entire AIRFLOW code base? We pip install airflow, and AIRFLOW_HOME points to a separate directory that just has airflow.cfg, dags dir, etc. I'm not sure that this would work for us, since git_version would be under the Python package dir, not AIRFLOW_HOME.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We will need to iterate on this as we learn more about how different companies install. This feature could be the forcing function.

git_version = f.readline()
except Exception as e:
self.logger.error(e)
Expand Down
63 changes: 35 additions & 28 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,41 +39,48 @@ def run(self):


def git_version(version):
"""
Return a version to identify the state of the underlying git repo. The version will
indicate whether the head of the current git-backed working directory is tied to a
release tag or not : it will indicate the former with a 'release:{version}' prefix
and the latter with a 'dev0' prefix. Following the prefix will be a sha of the current
branch head. Finally, a "dirty" suffix is appended to indicate that uncommitted changes
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dirty is a great idea...

are present.
"""
repo = None
try:
import git
repo = git.Repo('.git')
except ImportError:
logger.warn('gitpython not found: Cannot compute the git version.')
return ''
try:
repo = git.Repo('.git')
except ImportError:
except Exception as e:
logger.warn('Git repo not found: Cannot compute the git version.')
return ''
sha = repo.head.commit.hexsha
if repo.is_dirty():
return '.dev0+{sha}.dirty'.format(sha=sha)
# commit is clean
# is it release of `version` ?
try:
tag = repo.git.describe(
match='[0-9]*', exact_match=True,
tags=True, dirty=True)
assert tag == version, (tag, version)
return '.release:{version}+{sha}'.format(version=version,
sha=sha)
except git.GitCommandError:
return '.dev0+{sha}'.format(sha=sha)


def write_version(filename=os.path.join('airflow', 'git_version')):
cnt = """%(git_revision)s"""
text = cnt % {'git_revision':
git_version(version)}
try:
with open(filename, 'w') as a:
a.write(text)
except Exception as e:
logger.error(e)
if repo:
sha = repo.head.commit.hexsha
if repo.is_dirty():
return '.dev0+{sha}.dirty'.format(sha=sha)
# commit is clean
# is it release of `version` ?
try:
tag = repo.git.describe(
match='[0-9]*', exact_match=True,
tags=True, dirty=True)
assert tag == version, (tag, version)
return '.release:{version}+{sha}'.format(version=version,
sha=sha)
except git.GitCommandError:
return '.dev0+{sha}'.format(sha=sha)
else:
return 'no_git_version'


def write_version(filename=os.path.join(*['airflow',
'git_version'])):
text = "{}".format(git_version(version))
with open(filename, 'w') as a:
a.write(text)


async = [
Expand Down