Skip to main content
  • Home
  • Development
  • Documentation
  • Donate
  • Operational login
  • Browse the archive

swh logo
SoftwareHeritage
Software
Heritage
Archive
Features
  • Search

  • Downloads

  • Save code now

  • Add forge now

  • Help

Revision 6161210037eedf38304dc60b8ed6c545faff1f06 authored by Yuxin Ma on 08 September 2020, 18:36:18 UTC, committed by Yuxin Ma on 08 September 2020, 18:36:18 UTC
readme updated
1 parent c438105
  • Files
  • Changes
  • cb297b1
  • /
  • app.py
Raw File Download
Permalinks

To reference or cite the objects present in the Software Heritage archive, permalinks based on SoftWare Hash IDentifiers (SWHIDs) must be used.
Select below a type of object currently browsed in order to display its associated SWHID and permalink.

  • revision
  • directory
  • content
revision badge
swh:1:rev:6161210037eedf38304dc60b8ed6c545faff1f06
directory badge Iframe embedding
swh:1:dir:cb297b1bb838f5038827ecc4194ef1f683763700
content badge Iframe embedding
swh:1:cnt:2642383c44c5074f9068967097faa4a2849ca610
Citations

This interface enables to generate software citations, provided that the root directory of browsed objects contains a citation.cff or codemeta.json file.
Select below a type of object currently browsed in order to generate citations for them.

  • revision
  • directory
  • content
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
app.py
#!/usr/bin/python3

import numpy as np
from sklearn.externals import joblib
from flask import Flask
from flask_restful import Api
from flask_cors import CORS
import json
from resources.data import Data
from resources.path import Path
from resources.utils import compute_relation_graph
import os


base_data_path = 'data/samples/shuttle/'

data_path = os.path.join(base_data_path, 'data.json')
model_file_names = {
    'correct_predict_labels_': os.path.join(base_data_path, 'correct_predict_labels.npy'),
    'correct_predict_idx_': os.path.join(base_data_path, 'correct_predict_idx.npy'),
    'smoothed_knn': os.path.join(base_data_path, 'smoothed_knn.joblib')
}

correct_predict_labels_ = np.load(model_file_names['correct_predict_labels_'])
correct_predict_idx_ = np.load(model_file_names['correct_predict_idx_'])
smoothed_knn = joblib.load(model_file_names['smoothed_knn'])

with open(data_path, 'r') as json_fin:
    json_data = json.load(json_fin)

Gs, Ps = compute_relation_graph(json_data)

"""
Flask starts here
"""

app = Flask(__name__)
api = Api(app)

# CORS for development purpose only
CORS(app, resources={r"/api/*": {"origins": "*"}})

api.add_resource(Data,
                 '/api/data',
                 resource_class_args=(json_data,))
api.add_resource(Path,
                 '/api/path',
                 resource_class_args=(
                     json_data,
                     Gs[5],
                     correct_predict_labels_,
                     correct_predict_idx_,
                     smoothed_knn
                 ))

if __name__ == '__main__':
    port = int(5000)
    app.run(host='127.0.0.1', port=port)
The diff you're trying to view is too large. Only the first 1000 changed files have been loaded.
Showing with 0 additions and 0 deletions (0 / 0 diffs computed)
swh spinner

Computing file changes ...

Software Heritage — Copyright (C) 2015–2025, The Software Heritage developers. License: GNU AGPLv3+.
The source code of Software Heritage itself is available on our development forge.
The source code files archived by Software Heritage are available under their own copyright and licenses.
Terms of use: Archive access, API— Contact— JavaScript license information— Web API

back to top