Skip to content

Commit

Permalink
precommit
Browse files Browse the repository at this point in the history
  • Loading branch information
MAVRICK-1 committed Feb 7, 2024
1 parent 98a99fa commit 4b842b7
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 13 deletions.
2 changes: 1 addition & 1 deletion iyp/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -704,4 +704,4 @@ def save_cached_object(self, object_name: str, object) -> None:
pickle.dump(object, f)

def clear_cache(self) -> None:
rmtree(self.cache_dir)
rmtree(self.cache_dir)
25 changes: 13 additions & 12 deletions iyp/crawlers/rovista/validating_rov.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,21 @@ def run(self):
offset = 0
entries = []
asns = set()

while True:
# Make a request with the current offset
response = requests.get(URL, params={'offset': offset, 'count': batch_size})
if response.status_code != 200:
raise RequestStatusError('Error while fetching RoVista data')

data = response.json().get('data', [])
for entry in data:
asns.add(entry['asn'])
if entry['ratio'] > 0.5:
entries.append({'asn':entry['asn'],'ratio':entry['ratio'],'label':'Validating RPKI ROV'})
entries.append({'asn': entry['asn'], 'ratio': entry['ratio'], 'label': 'Validating RPKI ROV'})
else:
entries.append({'asn':entry['asn'],'ratio':entry['ratio'],'label':'Not Validating RPKI ROV'})
entries.append({'asn': entry['asn'], 'ratio': entry['ratio'], 'label': 'Not Validating RPKI ROV'})

# Move to the next page
offset += 1
# Break the loop if there's no more data
Expand All @@ -43,21 +43,22 @@ def run(self):
logging.info('Pushing nodes to neo4j...\n')
# get ASNs and prefixes IDs
self.asn_id = self.iyp.batch_get_nodes_by_single_prop('AS', 'asn', asns)
tag_id_not_vali= self.iyp.get_node('Tag',{'label':"Not Validating RPKI ROV"},create=True)
tag_id_vali=self.iyp.get_node('Tag',{'label':"Validating RPKI ROV"},create=True)
tag_id_not_vali = self.iyp.get_node('Tag', {'label': 'Not Validating RPKI ROV'}, create=True)
tag_id_vali = self.iyp.get_node('Tag', {'label': 'Validating RPKI ROV'}, create=True)
# Compute links
links = []
for entry in entries:
asn_qid = self.asn_id[entry['asn']]
if entry['ratio'] > 0.5:
links.append({'src_id': asn_qid, 'dst_id':tag_id_vali , 'props': [self.reference, entry]})
else :
links.append({'src_id': asn_qid, 'dst_id':tag_id_not_vali , 'props': [self.reference, entry]})
links.append({'src_id': asn_qid, 'dst_id': tag_id_vali, 'props': [self.reference, entry]})
else:
links.append({'src_id': asn_qid, 'dst_id': tag_id_not_vali, 'props': [self.reference, entry]})

logging.info('Pushing links to neo4j...\n')
# Push all links to IYP
self.iyp.batch_add_links('CATEGORIZED', links)


def main() -> None:
parser = argparse.ArgumentParser()
parser.add_argument('--unit-test', action='store_true')
Expand Down Expand Up @@ -85,4 +86,4 @@ def main() -> None:

if __name__ == '__main__':
main()
sys.exit(0)
sys.exit(0)

0 comments on commit 4b842b7

Please sign in to comment.