Skip to content

Commit 0e0bf8d

Browse files
committed
adding documentation
1 parent aa7a8e5 commit 0e0bf8d

File tree

1 file changed

+32
-12
lines changed

1 file changed

+32
-12
lines changed

script/oca_to_linkml.py

+32-12
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,27 @@
66
#
77
# Author: Damion Dooley
88
#
9+
# Run this in folder where one wants DataHarmonizer schema to be built, so
10+
# typically, in some DH web/templates/[schema folder]/, which reads by default
11+
# a file called oca_bundle.json
12+
#
13+
# > python3 ../../../script/oca_to_linkml.py [-i oca_bundle_file_name]
14+
#
15+
# Output:
16+
# schema_core.yaml - the main LinkML upper structure within which slots and enums are added.
17+
# schema_slots.tsv - the list of column fields
18+
# schema_enums.tsv - the list of enumerations (code lists)
19+
#
20+
# Then in DH context, run "> python3 tabular_to_schema.py" to generate
21+
# schema.yaml - yaml version of complete LinkML schema for default language
22+
# schema.json - json version of complete LinkML schema for default language used by DataHarmonizer
23+
# and for any language locale variants, a language overlay file which is layered on top of the above schema.json file:
24+
# locales/[i18n locale code]/schema.yaml
25+
# locales/[i18n locale code]/schema.json
26+
#
27+
# DataHarmonizer can load the complete schema.json file directly via
28+
# "load template" option. However access to multilingual functionality will
29+
# require adding the complete schema into the schema bundle and menu.js file.
930

1031
import json
1132
import optparse
@@ -18,8 +39,6 @@
1839

1940
###############################################################################
2041

21-
input_oca_file = 'oca_bundle.json';
22-
schema_core_file = 'schema_core.yaml';
2342
warnings = [];
2443
locale_mapping = {}; # Converting OCA language terms to i18n
2544

@@ -91,16 +110,15 @@
91110

92111
def init_parser():
93112
parser = optparse.OptionParser()
94-
"""
113+
95114
parser.add_option(
96-
"-m",
97-
"--menu",
98-
dest="menu",
99-
default=False,
100-
action="store_true",
101-
help="A flag which indicates menu entries should be generated or updated for a schema's templates (classes).",
115+
"-i",
116+
"--input",
117+
dest="input_oca_file",
118+
default="oca_bundle.json",
119+
help="Provide an OCA json bundle file path and name to read.",
102120
)
103-
"""
121+
104122
return parser.parse_args();
105123

106124
def save_tsv(file_name, headers, data):
@@ -267,9 +285,11 @@ def writeEnums():
267285
options, args = init_parser();
268286

269287
# Load OCA schema bundle specification
270-
if os.path.isfile(input_oca_file):
271-
with open(input_oca_file, "r") as f:
288+
if options.input_oca_file and os.path.isfile(options.input_oca_file):
289+
with open(options.input_oca_file, "r") as f:
272290
oca_obj = json.load(f);
291+
else:
292+
os.exit("- [Input OCA bundle file is required]")
273293

274294
# In parsing input_oca_file, a few attributes are ignored for now in much of
275295
# the structure:

0 commit comments

Comments
 (0)