Exemplo n.º 1
0
 def load_predata(cls):
     cls.FILES_LIMIT = Preprocessor.data_files_limit
     if not cls.METRICS:
         cls.METRICS = Preprocessor.get_custom_metrics(['metric_name', 'total_score'])
     if not cls.SPDX_LICENSES:
         # cls.SPDX_LICENSES, cls.SPDX_LICENSE_NAMES, cls.SPDX_LICENSE_URLS = Preprocessor.get_licenses()
         cls.SPDX_LICENSES, cls.SPDX_LICENSE_NAMES = Preprocessor.get_licenses()
     if not cls.COMMUNITY_METADATA_STANDARDS_URIS:
         cls.COMMUNITY_METADATA_STANDARDS_URIS = Preprocessor.get_metadata_standards_uris()
         cls.COMMUNITY_METADATA_STANDARDS_URIS_LIST = list(cls.COMMUNITY_METADATA_STANDARDS_URIS.keys())
     if not cls.COMMUNITY_STANDARDS:
         cls.COMMUNITY_STANDARDS = Preprocessor.get_metadata_standards()
         cls.COMMUNITY_STANDARDS_NAMES = list(cls.COMMUNITY_STANDARDS.keys())
     if not cls.SCIENCE_FILE_FORMATS:
         cls.SCIENCE_FILE_FORMATS = Preprocessor.get_science_file_formats()
     if not cls.LONG_TERM_FILE_FORMATS:
         cls.LONG_TERM_FILE_FORMATS = Preprocessor.get_long_term_file_formats()
     if not cls.OPEN_FILE_FORMATS:
         cls.OPEN_FILE_FORMATS = Preprocessor.get_open_file_formats()
     if not cls.DEFAULT_NAMESPACES:
         cls.DEFAULT_NAMESPACES = Preprocessor.getDefaultNamespaces()
     if not cls.VOCAB_NAMESPACES:
         cls.VOCAB_NAMESPACES = Preprocessor.getLinkedVocabs()
     if not cls.STANDARD_PROTOCOLS:
         cls.STANDARD_PROTOCOLS = Preprocessor.get_standard_protocols()
Exemplo n.º 2
0
def main():
    logging.getLogger('connexion.operation').setLevel('INFO')
    ROOT_DIR = os.path.dirname(os.path.abspath(__file__))
    YAML_DIR = config['SERVICE']['yaml_directory']
    METRIC_YAML = config['SERVICE']['metrics_yaml']
    METRIC_YML_PATH = os.path.join(ROOT_DIR, YAML_DIR, METRIC_YAML)
    SPDX_URL = config['EXTERNAL']['spdx_license_github']
    DATACITE_API_REPO = config['EXTERNAL']['datacite_api_repo']
    RE3DATA_API = config['EXTERNAL']['re3data_api']
    METADATACATALOG_API = config['EXTERNAL']['metadata_catalog']
    LOV_API = config['EXTERNAL']['lov_api']
    LOD_CLOUDNET = config['EXTERNAL']['lod_cloudnet']
    #BIOPORTAL_REST = config['EXTERNAL']['bioportal_rest']
    #BIOPORTAL_APIKEY = config['EXTERNAL']['bioportal_apikey']
    data_files_limit = int(config['SERVICE']['data_files_limit'])
    metric_specification = config['SERVICE']['metric_specification']

    #TODO further implementation on authentication needed
    usr = config['USER']['usr']
    pwd = config['USER']['pwd']
    authen.service_username = usr
    authen.service_password = pwd

    preproc = Preprocessor()
    preproc.retrieve_metrics_yaml(METRIC_YML_PATH, data_files_limit, metric_specification)
    logger.info('Total metrics defined: {}'.format(preproc.get_total_metrics()))

    isDebug = config.getboolean('SERVICE', 'debug_mode')
    preproc.retrieve_licenses(SPDX_URL, isDebug)
    preproc.retrieve_datacite_re3repos(RE3DATA_API, DATACITE_API_REPO, isDebug)
    preproc.retrieve_metadata_standards(METADATACATALOG_API, isDebug)
    #preproc.retrieve_linkedvocabs(lov_api=LOV_API, lodcloud_api=LOD_CLOUDNET, bioportal_api=BIOPORTAL_REST, bioportal_key=BIOPORTAL_APIKEY, isDebugMode=False)
    preproc.retrieve_linkedvocabs(lov_api=LOV_API, lodcloud_api=LOD_CLOUDNET, isDebugMode=isDebug)
    preproc.retrieve_default_namespaces()

    logger.info('Total SPDX licenses : {}'.format(preproc.get_total_licenses()))
    logger.info('Total re3repositories found from datacite api : {}'.format(len(preproc.getRE3repositories())))
    logger.info('Total subjects area of imported metadata standards : {}'.format(len(preproc.metadata_standards)))
    logger.info('Total LD vocabs imported : {}'.format(len(preproc.getLinkedVocabs())))
    logger.info('Total default namespaces specified : {}'.format(len(preproc.getDefaultNamespaces())))

    #you can also use Tornado or gevent as the HTTP server, to do so set server to tornado or gevent
    app = connexion.FlaskApp(__name__, specification_dir=YAML_DIR)
    API_YAML = os.path.join(ROOT_DIR, YAML_DIR, config['SERVICE']['swagger_yaml'])
    app.app.json_encoder = encoder.JSONEncoder
    app.add_api(API_YAML, arguments={'title': 'F-UJI : FAIRsFAIR Research Data Object Assessment Service'}, validate_responses=True)
    app.app.wsgi_app = ProxyFix(app.app.wsgi_app)
    app.run(host=config['SERVICE']['service_host'], port=int(config['SERVICE']['service_port']))