-
Notifications
You must be signed in to change notification settings - Fork 34
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
Latest Version Changes #235
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,8 @@ FROM centos:7 | |
MAINTAINER Saleem Ansari <[email protected]> | ||
|
||
RUN yum install -y epel-release && \ | ||
yum install -y python-pip python-devel gcc && \ | ||
yum install -y python34-pip python34-devel gcc && \ | ||
yum install -y git && \ | ||
yum clean all | ||
|
||
# -------------------------------------------------------------------------------------------------------------- | ||
|
@@ -21,15 +22,14 @@ RUN yum install -y epel-release && \ | |
|
||
# Note: cron daemon ( crond ) will be invoked from within entry point | ||
# -------------------------------------------------------------------------------------------------------------- | ||
RUN pip3 install git+https://[email protected]/fabric8-analytics/fabric8-analytics-version-comparator.git | ||
RUN pip3 install git+https://github.com/fabric8-analytics/fabric8-analytics-utils.git | ||
|
||
# install python packages | ||
COPY ./requirements.txt / | ||
RUN pip install -r requirements.txt && rm requirements.txt | ||
|
||
COPY ./ /tmp/f8a_data_model/ | ||
COPY ./src /src | ||
RUN cd /tmp/f8a_data_model && pip3 install . | ||
|
||
ADD scripts/entrypoint.sh /bin/entrypoint.sh | ||
ADD populate_schema.py /populate_schema.py | ||
|
||
ENTRYPOINT ["/bin/entrypoint.sh"] | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,12 +18,12 @@ LABEL author "Devtools <[email protected]>" | |
|
||
# Note: cron daemon ( crond ) will be invoked from within entry point | ||
# -------------------------------------------------------------------------------------------------------------- | ||
RUN pip3 install git+https://[email protected]/fabric8-analytics/fabric8-analytics-version-comparator.git | ||
RUN pip3 install git+https://github.com/fabric8-analytics/fabric8-analytics-utils.git@latest | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
||
# install python packages | ||
COPY ./requirements.txt / | ||
RUN pip install -r requirements.txt && rm requirements.txt | ||
|
||
COPY ./ /tmp/f8a_data_model/ | ||
COPY ./src /src | ||
RUN cd /tmp/f8a_data_model && pip3 install . | ||
|
||
ADD scripts/entrypoint.sh /bin/entrypoint.sh | ||
ADD populate_schema.py /populate_schema.py | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
#!/usr/bin/env python | ||
#!/usr/bin/env python3 | ||
"""Populate graph schema.""" | ||
|
||
import logging | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,7 +25,6 @@ flake8==3.6.0 # via flake8-polyfill | |
flask-cors==3.0.7 | ||
flask==1.0.2 | ||
funcsigs==1.0.2 # via mock, pytest | ||
futures==3.2.0 # via s3transfer | ||
gevent==1.4.0 | ||
greenlet==0.4.15 # via gevent | ||
gunicorn==19.9.0 | ||
|
@@ -61,3 +60,5 @@ sqlalchemy==1.2.15 | |
urllib3==1.24.1 # via botocore, minio, requests | ||
uuid==1.30 | ||
werkzeug==0.14.1 # via flask, pytest-flask | ||
git+https://[email protected]/fabric8-analytics/fabric8-analytics-version-comparator.git@2e7eddc | ||
git+https://github.com/fabric8-analytics/fabric8-analytics-utils.git@d7aaccf |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
# 0 */6 * * * root . /root/project_env.sh; export PYTHONPATH=/src; python /src/data_importer.py -s S3 | ||
# 0 */6 * * * root . /root/project_env.sh; export PYTHONPATH=/src; python3 /src/data_importer.py -s S3 | ||
# An empty line is required at the end of this file for a valid cron file. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
#!/usr/bin/env python3 | ||
|
||
# Copyright © 2019 Red Hat Inc. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
# Author: Yusuf Zainee <[email protected]> | ||
# | ||
|
||
"""Project setup file for fabric8 analytics notifications project.""" | ||
|
||
from setuptools import setup, find_packages | ||
|
||
|
||
def get_requirements(): | ||
"""Parse all packages mentioned in the 'requirements.txt' file.""" | ||
with open('requirements.txt') as fd: | ||
lines = fd.read().splitlines() | ||
reqs, dep_links = [], [] | ||
for line in lines: | ||
if line.startswith('git+'): | ||
dep_links.append(line) | ||
else: | ||
reqs.append(line) | ||
return reqs, dep_links | ||
|
||
|
||
# pip doesn't install from dependency links by default, | ||
# so one should install dependencies by | ||
# `pip install -r requirements.txt`, not by `pip install .` | ||
# See https://github.com/pypa/pip/issues/2023 | ||
reqs, dep_links = get_requirements() | ||
setup( | ||
name='fabric8-analytics-data-model', | ||
version='0.1', | ||
scripts=[ | ||
], | ||
packages=find_packages(exclude=['tests', 'tests.*']), | ||
install_requires=reqs, | ||
dependency_links=dep_links, | ||
include_package_data=True, | ||
author='Yusuf Zainee', | ||
author_email='[email protected]', | ||
description='data importer for fabric8 analytics', | ||
license='ASL 2.0', | ||
keywords='fabric8-analytics-data-model', | ||
url=('https://github.com/fabric8-analytics/' | ||
'fabric8-analytics-data-model') | ||
) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,9 +5,10 @@ | |
import time | ||
from dateutil.parser import parse as parse_datetime | ||
from six import string_types | ||
import config | ||
from utils import get_current_version | ||
from src import config | ||
from src.utils import get_current_version | ||
from datetime import datetime | ||
from f8a_utils.versions import get_latest_versions_for_ep | ||
|
||
logger = logging.getLogger(config.APP_NAME) | ||
|
||
|
@@ -22,6 +23,9 @@ def construct_graph_nodes(cls, epv): | |
pkg_name = epv.get('name') | ||
version = epv.get('version') | ||
source_repo = epv.get('source_repo', '') | ||
latest_version = epv.get('latest_version', '') | ||
if not latest_version: | ||
latest_version = get_latest_versions_for_ep(ecosystem, pkg_name) | ||
if ecosystem and pkg_name and version: | ||
# Query to Create Package Node | ||
# TODO: refactor into the separate module | ||
|
@@ -33,8 +37,9 @@ def construct_graph_nodes(cls, epv): | |
"property('{ecosystem}_pkg_count',1)).iterate();" \ | ||
"graph.addVertex('ecosystem', '{ecosystem}', " \ | ||
"'name', '{pkg_name}', 'vertex_label', 'Package');}};" \ | ||
"pkg.property('latest_version', '{latest_version}');" \ | ||
"pkg.property('last_updated', {last_updated});".format( | ||
ecosystem=ecosystem, pkg_name=pkg_name, | ||
ecosystem=ecosystem, latest_version=latest_version, pkg_name=pkg_name, | ||
last_updated=str(time.time()) | ||
) | ||
|
||
|
@@ -487,6 +492,7 @@ def create_query_string(cls, input_json): | |
str_gremlin += str_gremlin_version | ||
if not prp_package: | ||
# TODO: refactor into the separate module | ||
latest_version = get_latest_versions_for_ep(ecosystem, pkg_name) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm, why do we call There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is my biggest issue with this PR :) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The reason is that different APIs are triggering different functional flows, where gremlin queries are getting generated for the package node. So basically thats 2 of them. The 3rd one, construct graph node function, i have added it so that even in cases where we are creating dummy nodes during CVEs etc, the package node should get updated to the latest version. This is an extra check added to make sure that our package node is always updated. |
||
str_gremlin += "pkg = g.V().has('ecosystem','{ecosystem}')." \ | ||
"has('name', '{pkg_name}').tryNext().orElseGet{{" \ | ||
"g.V().has('vertex_label','Count').choose(has('" \ | ||
|
@@ -496,9 +502,10 @@ def create_query_string(cls, input_json): | |
"'{ecosystem}_pkg_count',1)).iterate();graph.addVertex(" \ | ||
"'ecosystem', '{ecosystem}', 'name', '{pkg_name}', " \ | ||
"'vertex_label', 'Package');}};" \ | ||
"pkg.property('latest_version', '{latest_version}');" \ | ||
"pkg.property('last_updated', {last_updated});".format( | ||
ecosystem=ecosystem, pkg_name=pkg_name, | ||
last_updated=str(time.time()) | ||
ecosystem=ecosystem, latest_version=latest_version, | ||
pkg_name=pkg_name, last_updated=str(time.time()) | ||
) | ||
# TODO: refactor into the separate module | ||
str_gremlin += "edge_c = g.V().has('pecosystem','{ecosystem}').has('pname'," \ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't be better to install specific versions of these dependencies?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes i will make those changes in the final commit. Still its WIP as the tests are not passing.