• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

WISDEM / WEIS / 13100922929

02 Feb 2025 05:22PM UTC coverage: 55.96% (-22.0%) from 77.973%
13100922929

push

github

gbarter
trying latest versions of openfast and rosco

6591 of 11778 relevant lines covered (55.96%)

0.56 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

83.91
/weis/inputs/validation.py
1
import os
1✔
2
import jsonmerge
1✔
3
import wisdem.inputs
1✔
4
from wisdem.inputs.validation import load_yaml, write_yaml, _validate, simple_types, DefaultValidatingDraft7Validator
1✔
5
import rosco.toolbox.inputs
1✔
6
from openfast_io.FileTools import remove_numpy
1✔
7

8
froot_wisdem           = os.path.dirname(wisdem.inputs.__file__)
1✔
9
fschema_geom_wisdem    = os.path.join(froot_wisdem, 'geometry_schema.yaml')
1✔
10
fschema_model_wisdem   = os.path.join(froot_wisdem, 'modeling_schema.yaml')
1✔
11
fschema_opt_wisdem     = os.path.join(froot_wisdem, 'analysis_schema.yaml')
1✔
12

13
froot_rosco            = os.path.dirname(rosco.toolbox.inputs.__file__)
1✔
14
fschema_model_rosco    = os.path.join(froot_rosco, 'toolbox_schema.yaml')
1✔
15

16
froot           = os.path.dirname(os.path.realpath(__file__))
1✔
17
fdefaults_geom  = os.path.join(froot, 'geometry_defaults.yaml')
1✔
18
fschema_geom    = os.path.join(froot, 'geometry_schema.yaml')
1✔
19
fschema_model   = os.path.join(froot, 'modeling_schema.yaml')
1✔
20
fschema_opt     = os.path.join(froot, 'analysis_schema.yaml')
1✔
21

22
fschema_openfast       = os.path.join(froot, 'openfast_schema.yaml')
1✔
23
#---------------------
24
def load_default_geometry_yaml():
1✔
25
    return load_yaml(fdefaults_geom)
×
26

27
def get_geometry_schema():
1✔
28
    wisdem_schema = load_yaml(fschema_geom_wisdem)
1✔
29
    weis_schema   = load_yaml(fschema_geom)
1✔
30
    merged_schema = jsonmerge.merge(wisdem_schema, weis_schema)
1✔
31
    return merged_schema
1✔
32

33
def load_geometry_yaml(finput):
1✔
34
    merged_schema = get_geometry_schema()
1✔
35
    return _validate(finput, merged_schema, defaults=True)
1✔
36

37
def write_geometry_yaml(instance, foutput):
1✔
38
    merged_schema = get_geometry_schema()
×
39
    _validate(instance, merged_schema, defaults=False)
×
40
    sfx_str = '.yaml'
×
41
    if foutput[-5:] == sfx_str:
×
42
        sfx_str = ''
×
43
    write_yaml(instance, foutput+sfx_str)
×
44

45
def get_modeling_schema():
1✔
46
    wisdem_schema = load_yaml(fschema_model_wisdem)
1✔
47
    rosco_schema  = load_yaml(fschema_model_rosco)
1✔
48
    openfast_schema = load_yaml(fschema_openfast)
1✔
49
    weis_schema   = load_yaml(fschema_model)
1✔
50

51
    # Merge ROSCO options and update modeling
52
    merged_rosco_schema = jsonmerge.merge(rosco_schema['properties']['controller_params'], weis_schema['properties']['ROSCO'])
1✔
53
    merged_rosco_schema['properties']['linmodel_tuning'] = rosco_schema['properties']['linmodel_tuning']
1✔
54
    weis_schema['properties']['ROSCO'].update(merged_rosco_schema)
1✔
55
    
56
    # Update WEIS schema with WISDEM schema
57
    weis_schema['properties']['WISDEM'].update( wisdem_schema['properties']['WISDEM'] )
1✔
58

59
    # Update WEIS schema with OpenFAST schema
60
    weis_schema['properties']['OpenFAST'].update( openfast_schema['properties']['OpenFAST'] )
1✔
61

62

63
    return weis_schema
1✔
64

65
def load_modeling_yaml(finput):
1✔
66
    weis_schema = get_modeling_schema()
1✔
67
    return _validate(finput, weis_schema, defaults=True)
1✔
68

69
def write_modeling_yaml(instance, foutput):
1✔
70
    weis_schema = get_modeling_schema()
1✔
71
    sfx_str = ".yaml"
1✔
72
    if foutput[-5:] == sfx_str:
1✔
73
        foutput = foutput[-5:]
×
74
    elif foutput[-4:] == ".yml":
1✔
75
        foutput = foutput[-4:]
×
76
    sfx_str = "-modeling.yaml"
1✔
77
    instance2 = simple_types(instance)
1✔
78
    instance2 = remove_numpy(instance2)
1✔
79
    _validate(instance2, weis_schema, defaults=False)
1✔
80
    write_yaml(instance2, foutput+sfx_str)
1✔
81

82
def get_analysis_schema():
1✔
83
    wisdem_schema = load_yaml(fschema_opt_wisdem)
1✔
84
    weis_schema   = load_yaml(fschema_opt)
1✔
85
    merged_schema = jsonmerge.merge(wisdem_schema, weis_schema)
1✔
86
    return merged_schema
1✔
87

88
def load_analysis_yaml(finput):
1✔
89
    merged_schema = get_analysis_schema()
1✔
90
    return _validate(finput, merged_schema, defaults=True)
1✔
91

92
def write_analysis_yaml(instance, foutput):
1✔
93
    merged_schema = get_analysis_schema()
1✔
94
    _validate(instance, merged_schema, defaults=False)
1✔
95
    sfx_str = ".yaml"
1✔
96
    if foutput[-5:] == sfx_str:
1✔
97
        foutput = foutput[-5:]
×
98
    elif foutput[-4:] == ".yml":
1✔
99
        foutput = foutput[-4:]
×
100
    sfx_str = "-analysis.yaml"
1✔
101
    write_yaml(instance, foutput+sfx_str)
1✔
102

103
def re_validate_modeling(modeling_dict):
1✔
104
    fschema = get_modeling_schema()
1✔
105
    yaml_schema = load_yaml(fschema) if isinstance(fschema, type("")) else fschema
1✔
106
    DefaultValidatingDraft7Validator(yaml_schema).validate(modeling_dict)
1✔
107

108
def re_validate_analysis(analysis_dict):
1✔
109
    fschema = get_analysis_schema()
×
110
    yaml_schema = load_yaml(fschema) if isinstance(fschema, type("")) else fschema
×
111
    DefaultValidatingDraft7Validator(yaml_schema).validate(analysis_dict)
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc