E3SM-Project / pace

Performance Analytics for Computational Experiments
https://pace.ornl.gov
BSD 3-Clause "New" or "Revised" License
3 stars 0 forks source link

Parse compiler and mpilib from env_build.xml #84

Closed sarats closed 2 years ago

sarats commented 2 years ago

env_build.xml has these variables. Parse and add to e3smexp.

239   <group id="build_macros">
240     <entry id="OS" value="LINUX">
241       <type>char</type>
242       <valid_values/>
243       <desc>Operating system - DO NOT EDIT UNLESS for userdefined machine - ignored once Macros has been created.</desc>
244     </entry>
245     <entry id="COMPILER" value="intel">
246       <type>char</type>
247       <valid_values/>
248       <desc>Machine compiler (must match one the supported compilers)
249     Set in $CIMEROOT/machines/config_machines.xml for each supported machine.
250     Must be explicitly set in env_build.xml for userdefined machine.</desc>
251     </entry>
252     <entry id="MPILIB" value="openmpi">
253       <type>char</type>
254       <valid_values/>
255       <desc>mpi library (must match one of the supported libraries) -
256     ignored once Macros has been created
257     Set in $CIMEROOT/machines/config_machines.xml for each supported machine.
258     Must be explicitly set in env_build.xml for userdefined machine.</desc>
259     </entry>

Also need to think if threaded build is enabled and record that.

200     <entry id="SMP_PRESENT" value="TRUE">
201       <type>logical</type>
202       <valid_values>TRUE,FALSE</valid_values>
203       <desc>TRUE implies that at least one of the components is built threaded (DO NOT EDIT)</desc>                                   204     </entry>
sarats commented 2 years ago

def searchUpdate(db, field, fname):
    # Test using something like LIMIT 2 
    # myset = db.execute("select expid,  JSON_SEARCH(data, 'one', '" + field  + "') from xml_inputs where name = '" + fname + "' and JSON_SEARCH(data, 'one', '" + field  + "') is not NULL LIMIT 2").fetchall()
    myset = db.execute("select expid,  JSON_SEARCH(data, 'one', '" + field  + "') from xml_inputs where name = '" + fname + "' and JSON_SEARCH(data, 'one', '" + field  + "') is not NULL ").fetchall()
    count = 0
    for i in myset:
        eid = i[0]
        # print (eid)
        pos = i[1]
        # print (pos)
        reqfield = pos.partition('@')[0] + '@value"'
        # print (reqfield)
        value = db.execute("select JSON_VALUE(data, " + reqfield + ") from xml_inputs where name = '" + fname + "'  and expid = " + str(eid)).fetchall()[0][0]
        # print(value)
        if value is not None:
            count = count + 1
            print(value)
            # set fieldname as lowercase (e.g., COMPILER -> compiler)
            db.execute("update e3smexp set " + field.lower() + " = '" + value + "' where expid = " + str(eid) + " and " + field + " is NULL")
        print (count)
    return(0)

if __name__ == "__main__":
    # if sys.argv[1]:
        # filename = sys.argv[1]
    # mydburl = initDatabase()
    # mydb = create_engine(mydburl, echo=True)
    mydb = create_engine(mydburl, echo=False)

    searchUpdate(mydb, 'COMPILER', 'env_build.xml')
    searchUpdate(mydb, 'MPILIB', 'env_build.xml')

    exit(0)