wrapUpload.py

A researcher runs the Python program wrapUpload.py to upload results to the server. The program takes as input either ...

  • A directory tree, in which case command line parameters control which subdirectories are accepted for uploading.
  • A list of specific directories to upload.

The wrapUpload program creates a unique identifier for this upload, called the wrapId. See the SQL database overview for more information on the wrapId.

Then wrapUpload makes a list of all files to be uploaded. These must be in directories that passed the filters above and is restricted to the files:

  • metadata: user-specified metadata like name and publication DOI.
  • INCAR: Main list of parameters.
  • KPOINTS: Specify the k-point grid.
  • POSCAR: Specify atom positions.
  • POTCAR: Specify atomic pseudopotentials.
  • OUTCAR: General log and results in human-readable format.
  • vasprun.xml: All results in XML format.

Then wrapUpload makes a single JSON file, wrapId.json, containing metadata such as the list of directories. Then wrapUpload makes a single compressed tar file, wrapId.tgz, containing all the files. Finally wrapUpload uses scp to upload three files:

  • wrapId.json: General statistics and information
  • wrapId.tgz: Compendium of all files to be archived.
  • wrapId.zzflag: Zero-length flag.

The wrapId.zzflag file gets uploaded last. The server process wrapReceive doesn’t start processing the files until receiving the flag file, thereby preventing the server from starting to process partly-received data.


nrelmat.wrapUpload.main()[source]

Locates model runs, checks and extracts dir contents, and uses tar and scp to send the data to the server running wrapReceive.

Command line parameters:

Parameter Type Description
-bugLev integer Debug level. Normally 0.
-readType string If ‘outcar’, read the OUTCAR files. Else if ‘xml’, read the vasprun.xml files.
-requireInput boolean no/yes: do we require that the files INCAR, KPOINTS, POSCAR exist.
-requireIcsd boolean no/yes: do we require that the file path names contain ICSD info. See notes below.
-keepList string File containing the absolute paths of the dirs to be uploaded. Still topDir must be specified, and all paths in keepList must start with the specified topDir. If keepList is specified, keepPatterns and omitPatterns must not be specified. If none of keepList, keepPatterns, or omitPattens are specified, all dirs below topDir containing a metadata file will be archived.
-keepPatterns string Comma separated list of regular expressions matching the relative paths of those directories to be kept. If specified, keepList must not be specified.
-omitPatterns string Comma separated list of regular expressions matching the relative paths of those directories to be omitted. If specified, keepList must not be specified.
-topDir string Top of dir tree to upload.
-workDir string Work dir

If requireIcsd is true, getIcsdMap() must be able to extract ICSD info from the file names. File names must be like:

.../icsd_083665/icsd_083665.cif/ls-anti-ferro-7/relax_cellshape/1
         ^^^^^^                 ^^^^^^^^      ^ ^^^^^^^^^^^^^^^ ^
        icsdNum                 magType  magNum relaxType       relaxNum
nrelmat.wrapUpload.doUpload(bugLev, requireNames, optionNames, requireIcsd, keepList, keepPatterns, omitPatterns, topDir, workDir)[source]

Locates model runs, checks and extracts dir contents, and uses tar and scp to send the data to the server running wrapReceive.

If keepList is specified, creates keepAbsPaths = unique absolute paths and calls iterateDirs().

Otherwise calls searchDirs() to recursively search the directory tree starting at topDir.

Parameters:

  • bugLev (int): Debug level. Normally 0.
  • requireNames (str[]): names of required files.
  • optionNames (str[]): names of optional files.
  • requireIcsd (boolean): if True, the absTopDir string must contain ICSD info that getIcsdMap() can extract.
  • keepList (str[]): List of the absolute paths of the dirs to be uploaded, or None. Still topDir must be specified, and all paths in keepList must start with the specified topDir. If keepList is specified, keepPatterns and omitPatterns must not be specified.
  • keepPatterns (str[]): List of regular expressions matching the relative paths of those directories to be kept. If specified, keepList must not be specified.
  • omitPatterns (str[]): List of regular expressions matching the relative paths of those directories to be omitted. If specified, keepList must not be specified.
  • topDir (str): Top of dir tree to upload.
  • workDir (str): Work dir

Returns

  • None
nrelmat.wrapUpload.searchDirs(bugLev, requireNames, optionNames, keepPatterns, omitPatterns, absTopDir, relPath, requireIcsd, warnings, relDirs, relFiles)[source]

Recursive: locates model runs, checks dir contents, and appends names to lists of dirs and files.

Parameters:

  • bugLev (int): Debug level. Normally 0.
  • requireNames (str[]): names of required files.
  • optionNames (str[]): names of optional files.
  • keepPatterns (str[]): List of regular expressions matching the relative paths of those directories to be kept. If specified, keepList must not be specified.
  • omitPatterns (str[]): List of regular expressions matching the relative paths of those directories to be omitted. If specified, keepList must not be specified.
  • absTopDir (str): Absolute path of the original top of dir tree to upload.
  • relPath (str): Relative path so far, somewhere below absTopDir.
  • requireIcsd (boolean): if True, the absTopDir string must contain ICSD info that getIcsdMap() can extract.
  • relDirs (str[]): We append dirs to be archived.
  • relFiles (str[]): We append file names to be archived.

Returns

  • None
nrelmat.wrapUpload.iterateDirs(bugLev, requireNames, optionNames, keepAbsPaths, absTopDir, requireIcsd, warnings, relDirs, relFiles)[source]

For each path in keepAbsPaths, checks dir contents, and appends names to lists of dirs and files.

Parameters:

  • bugLev (int): Debug level. Normally 0.
  • requireNames (str[]): names of required files.
  • optionNames (str[]): names of optional files.
  • keepAbsPaths (str[]): List of absolute paths of dirs to archive.
  • absTopDir (str): Absolute path of the original top of dir tree to upload.
  • requireIcsd (boolean): if True, the absTopDir string must contain ICSD info that getIcsdMap() can extract.
  • relDirs (str[]): We append dirs to be archived.
  • relFiles (str[]): We append file names to be archived.

Returns

  • None
nrelmat.wrapUpload.processDir(bugLev, requireNames, optionNames, absTopDir, relPath, requireIcsd, warnings, relFiles)[source]

Prepares to archive a single directory, and appends names to lists of dirs and files.

Parameters:

  • bugLev (int): Debug level. Normally 0.
  • requireNames (str[]): names of required files.
  • optionNames (str[]): names of optional files.
  • absTopDir (str): Absolute path of the original top of dir tree to upload.
  • relPath (str): Relative path so far, somewhere below absTopDir.
  • requireIcsd (boolean): if True, the absTopDir string must contain ICSD info that getIcsdMap() can extract.
  • relFiles (str[]): We append file names to be archived.

Returns

  • None
nrelmat.wrapUpload.getIcsdMap(bugLev, relPath)[source]

Creates a map of ICSD info based on the dir name.

Example parsing inDir:

.../icsd_083665/icsd_083665.cif/ls-anti-ferro-7/relax_cellshape/1
         ^^^^^^                 ^^^^^^^^      ^ ^^^^^^^^^^^^^^^ ^
        icsdNum                 magType  magNum relaxType       relaxNum

Resulting map:

icsdMap = {
  'icsdNum'   : 83665,
  'magType'   : 'lsaf',
  'magNum'    : 7,
  'relaxType' : 'rc',
  'relaxNum'  : 1,
}

Parameters:

  • bugLev (int): Debug level. Normally 0.
  • relPath (str): Relative path.

Returns

  • map similar to the above.
nrelmat.wrapUpload.unused_extractPotcar(fname)[source]

(No longer used): Reads and saves the header sections from a POTCAR file.

Saves every section starting with ‘PAW_PBE’ to the following line ‘Description’.

Parameters:

  • fname (str): Name of the input POTCAR file.

Returns

  • List of pairs: [ specieName, listOfSavedLines]
nrelmat.wrapUpload.parseMetadata(fpath)[source]

Parses a metadata file and returns a corresponding map.

Parameters:

  • fpath (str): Name of the input metadata file.

Returns

  • Map of metadata values. The map structure is:

    Key

    Value Type

    Source description

    firstName

    str

    Researcher first name

    lastName

    str

    Researcher last name

    spacegroup

    str

    international space group number

    parents

    str[]

    comma separated list of sha1sum(s) of the vasprun.xml files of previous runs, if any

    publications

    str[]

    comma separated list of DOIs without the leading http://

    standards

    str[]

    comma separated list of standardized keywords

    keywords

    str[]

    comma separated list of any keywords

    notes

    str

    textual notes

nrelmat.wrapUpload.checkFileFull(fname)[source]

Insures that fname exists and has length > 0.

Parameters:

  • fname (str): Name of the input file.

Returns

  • None

Raises:

  • Exception if fname does not exist or has length == 0.
nrelmat.wrapUpload.checkFile(fname)[source]

Insures that fname exists. It may have length == 0.

Parameters:

  • fname (str): Name of the input file.

Returns

  • None

Raises:

  • Exception if fname does not exist.
nrelmat.wrapUpload.runSubprocess(bugLev, wkDir, args, showStdout)[source]

Calls the executable indicated by args and waits for completion.

Parameters:

  • bugLev (int): Debug level. Normally 0.
  • wkDir (str): The working directory to use for the subprocess.
  • args (str[]): The executable name (in args[0]) followed by the command line arguments in args[1:].
  • showStdout (boolean): If True, print the stdout from the subprocess.

Returns

  • None

Raises:

  • Exception if subprocess rc != 0.
nrelmat.wrapUpload.findNumFiles(tag, dir)[source]

Finds the number of files having name == tag in the tree at dir. Yes, Python has os.walk, but this is better.

Parameters:

  • tag (str): The name to search for.
  • dir (str): The root of the directory tree to search.

Returns

  • integer number of matches.
nrelmat.wrapUpload.formatUui(curDate, userId, absTopDir)[source]

Formats a uui (wrapId).

A wrapId looks like:

@2013.08.13@12.58.22.735311@someUser@home.someUser.redmesa.old.td.testlada.2013.04.06.Fe.O@

Parameters:

  • curDate (datetime.datetime): The current date.
  • userId (str): The current user id.
  • absTopDir (str): The absolute path of the top dir.

Returns

  • A wrapId
nrelmat.wrapUpload.parseUui(stg)[source]

Parses a uui (wrapId).

A wrapId looks like: ::
@2013.08.13@12.58.22.735311@someUser@home.someUser.redmesa.old.td.testlada.2013.04.06.Fe.O@

The input string may have subdirs info after the initial wrapId.

Parameters:

  • stg (str): The string to be parsed.

Returns

  • If stg is a valid wrapId, returns the wrapId == stg. Else returns None.
nrelmat.wrapUpload.printMap(tag, vmap, maxLen)[source]

Prints a map.

Parameters:

  • tag (str): Explanatory name of the map.
  • vmap (map): The map to print.
  • maxLen (int): The max length to use in printing a value, or 0.

Returns

  • None
nrelmat.wrapUpload.formatMatrix(mat)[source]

Formats a 2D matrix.

Parameters:

  • mat (float[][] or numpy 2D array): input matrix

Returns

  • string representation of the matrix.
nrelmat.wrapUpload.throwerr(msg)[source]

Prints an error message and raises Exception.

Parameters:

  • msg (str): Error message.

Returns

  • (Never returns)

Raises

  • Exception

Previous topic

wrapReceive.py

Next topic

Welcome to schedMain’s documentation!

This Page