Skip to content

Scripting Tool

Alasdair Gray edited this page Jul 26, 2022 · 21 revisions

Description

The Scripting Tool (generateBioschemasFiles.py) uses declarative descriptions of the Bioschemas profiles in conjunction with additional information (Schema.org and Bioschemas types) to generate the files (JSON-Schema and JSON). These required files allow the Web Application to support the users in the creation of markup based on the Bioschemas profiles.

Dependencies

  • Python (Developed using Version 3.6.8)
  • PyYAML (Developed using Version 5.1)
    • Can be installed using pip install PyYAML
  • requests
    • Often already installed; if not pip install requests
  • Configuration File (ConfigFile.ini)
    • Located in the folder /Scripting-Tool

Configuration File

[Github]
url = https://github.com/BioSchemas/bioschemas.github.io/archive/master.zip
currentProfilesDirectoryPath = /bioschemas.github.io-master/pages/_profiles/
currentTypesDirectoryPath = /bioschemas.github.io-master/pages/_types/
draftProfilesDirectoryPath = /bioschemas.github.io-master/_devSpecs/
draftTypesDirectoryPath = /bioschemas.github.io-master/_devTypes/

[Bioschemas]
url = http://bio.sdo-bioschemas-227516.appspot.com/

[SchemaOrg]
url = https://schema.org/

Usage

Output

The Scripting Tool will produce the following four folders located in the same folder as the Python script 'generateBioschemasFiles.py':

  • Current Profiles
    • profiles
    • tables
  • Draft Profiles
    • draft-profiles
    • draft-tables

Folders profiles and draft-profiles contain the JSON-Schema of the Bioschemas profiles.
Folders tables and draft-tables contain JSON files that store additional information about the Bioschemas profiles.

Error Messages and Handling

When running the Scripting Tool errors may occur. The following errors are the most likely to occur:

  • Error: fetchSchemaDescription for Schema.org property: 'Insert Property Name Here'
    • This error will not be detrimental to the process. Typically happens if a Bioschemas type is not listed in types folder and thus thinks it is a Schema.org type.
  • Error: createJSONSchema / Error: createJSONTable
    • This error is detrimental to the creation of current profile being processed. Typically happens if the definition of the profile does not contain the relevant information e.g mapping information.
    • If this error is encountered the script will be produce erroneous JSON-Schema and JSON files and thus the profiles that encounter this error must be removed from the folders before being deployed.
  • Error: addMinimumDefinition for profile: 'Insert Profile Name Here'
    • This error will not be detrimental to the process although any profiles references within a profile will not be able to marked up. Typically happens in conjunction with the previous errors createJSONSchema and createJSONTable.

Testing Generated Files

  • JSON-Schema generated can be easily tested by using an interactive demo provided by JSON-Editor's developers located at: https://json-editor.github.io/json-editor/.
  • Simply copy and paste a JSON-Schema for a profile into the textbox and click "Update Schema".
  • Any errors that occur are displayed in the web browsers console.
Clone this wiki locally