Changeset 4425


Ignore:
Timestamp:
May 3, 2007, 6:23:44 PM (18 years ago)
Author:
ole
Message:

Added points datafile as a caching dependency.
Also implemented that caching now throws an error if dependency file has been removed after caching has taken place.

Location:
anuga_core/source/anuga
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • anuga_core/source/anuga/caching/caching.py

    r4333 r4425  
    282282  # Force singletons into a tuple.
    283283  #
     284
    284285  if dependencies and type(dependencies) != types.TupleType \
    285286                  and type(dependencies) != types.ListType:
     
    817818  (argsfile,compressed1) = myopen(CD+FN+'_'+file_types[1],"rb",compression)
    818819  (admfile,compressed2) =  myopen(CD+FN+'_'+file_types[2],"rb",compression)
     820
     821  if verbose is True and deps is not None:
     822    print 'Caching: Dependencies are', deps.keys()
    819823
    820824  if not (argsfile and datafile and admfile) or \
     
    15041508  import types
    15051509
     1510  #print 'Caching DEBUG: Dependencies are', dependencies
    15061511  d = {}
    15071512  if dependencies:
     
    15121517    for FN in dependencies:
    15131518      expanded_FN = glob.glob(FN)
    1514      
     1519
     1520      if expanded_FN == []:
     1521        errmsg = 'ERROR (caching.py): Dependency '+FN+' does not exist.'
     1522        raise Exception, errmsg     
     1523
    15151524      expanded_dependencies += expanded_FN
    15161525
     
    15191528      if not type(FN) == types.StringType:
    15201529        errmsg = 'ERROR (caching.py): Dependency must be a string.\n'
    1521         errmsg += '                    Dependency given: %s' %FN
     1530        errmsg += '                   Dependency given: %s' %FN
    15221531        raise Exception, errmsg     
    15231532      if not os.access(FN,os.F_OK):
  • anuga_core/source/anuga/fit_interpolate/fit.py

    r4269 r4425  
    433433                attribute_name=None,
    434434                use_cache = False):
     435    """Wrapper around internal function _fit_to_mesh for use with caching.
     436   
     437    """
     438   
    435439    args = (vertex_coordinates, triangles, point_coordinates, )
    436440    kwargs = {'point_attributes': point_attributes,
     
    444448              'use_cache':use_cache
    445449              }
     450
    446451    if use_cache is True:
     452        if isinstance(point_coordinates, basestring):
     453            # We assume that point_coordinates is the name of a .csv/.txt
     454            # file which must be passed onto caching as a dependency (in case it
     455            # has changed on disk)
     456            dep = [point_coordinates]
     457        else:
     458            dep = None
     459
    447460        return cache(_fit_to_mesh,
    448461                     args, kwargs,
    449462                     verbose=verbose,
    450                      compression=False)
     463                     compression=False,
     464                     dependencies=dep)
    451465    else:
    452466        return apply(_fit_to_mesh,
Note: See TracChangeset for help on using the changeset viewer.