Exemplo n.º 1
0
    def test3NonTransfers(self):
        """Verify that temporary configurables leave nothing in the catalogue"""

        from AthExHelloWorld.AthExHelloWorldConf import HelloAlg

        name = 'test3NonTransfers'
        HelloWorld = HelloAlg(name)
        HelloWorld.MyInt = 666

        # adding, using, and subsequently removing to sequence should be a no-op
        seq = AlgSequence(name + 'Sequence')
        seq += HelloWorld
        getattr(seq, name).MyDouble = 2.71828
        exec 'del seq.%s' % name
        seq.setup()

        self.assert_(name not in JobOptionsSvc.getClients())

        del HelloWorld

        # oddity: give locals a kick to get the frame cleaned up
        locals()

        # after complete removal of the configurable, it should be history-less
        HelloWorld = HelloAlg(name)

        self.assertRaises(AttributeError, getattr, HelloWorld, 'MyInt')
        self.assertRaises(AttributeError, getattr, HelloWorld, 'MyDouble')
Exemplo n.º 2
0
   def test3NonTransfers( self ):
      """Verify that temporary configurables leave nothing in the catalogue"""

      from AthExHelloWorld.AthExHelloWorldConf import HelloAlg

      name = 'test3NonTransfers'
      HelloWorld = HelloAlg( name )
      HelloWorld.MyInt = 666

    # adding, using, and subsequently removing to sequence should be a no-op
      seq = AlgSequence( name + 'Sequence' )
      seq += HelloWorld
      getattr(seq,name).MyDouble = 2.71828
      exec 'del seq.%s' % name
      seq.setup()

      self.assert_( name not in JobOptionsSvc.getClients() )

      del HelloWorld

    # oddity: give locals a kick to get the frame cleaned up
      locals()

    # after complete removal of the configurable, it should be history-less
      HelloWorld = HelloAlg( name )

      self.assertRaises( AttributeError, getattr, HelloWorld, 'MyInt' )
      self.assertRaises( AttributeError, getattr, HelloWorld, 'MyDouble' )
Exemplo n.º 3
0
   def test2SetToolProperties( self ):
      """Test setting of tool properties"""

      from AthExHelloWorld.AthExHelloWorldConf import HelloAlg
      from AthExHelloWorld.AthExHelloWorldConf import HelloTool

      HelloWorld = HelloAlg( 'HelloWorld' )

      msg1 = "A Private Message!"

      HelloWorld.MyPrivateHelloTool = HelloTool( "HelloTool" )
      HelloWorld.MyPrivateHelloTool.MyMessage = msg1

      HelloWorld.setup()

      global ToolSvc

      msg2 = "A Public Message!"

      ToolSvc += HelloTool( "PublicHello" )
      ToolSvc.PublicHello.MyMessage = msg2

      ToolSvc.setup()

      self.assertEqual( HelloWorld.MyPrivateHelloTool.MyMessage, msg1 )
      client = HelloWorld.getName() + '.' + HelloWorld.MyPrivateHelloTool.getName()
      self.assert_( JobOptionsSvc.verify( client, 'MyMessage', msg1 ) )

      self.assertEqual( ToolSvc.PublicHello.MyMessage, msg2 )
      self.assert_( JobOptionsSvc.verify( 'ToolSvc.PublicHello', 'MyMessage', msg2 ) )
Exemplo n.º 4
0
    def test4HistoryBehavior(self):
        """Verify that name-uniqueness is preserved"""

        from AthExHelloWorld.AthExHelloWorldConf import HelloAlg

        name, value = 'test3NonTransfers', 888888
        HelloWorld = HelloAlg(name)
        HelloWorld.MyInt = value

        Hello2 = HelloAlg(name)

        self.assertEqual(HelloWorld.MyInt, Hello2.MyInt)

        del HelloWorld
        self.assertEqual(Hello2.MyInt, value)
Exemplo n.º 5
0
   def test4HistoryBehavior( self ):
      """Verify that name-uniqueness is preserved"""

      from AthExHelloWorld.AthExHelloWorldConf import HelloAlg

      name, value = 'test3NonTransfers', 888888
      HelloWorld = HelloAlg( name )
      HelloWorld.MyInt = value

      Hello2 = HelloAlg( name )

      self.assertEqual( HelloWorld.MyInt, Hello2.MyInt )

      del HelloWorld
      self.assertEqual( Hello2.MyInt, value )
Exemplo n.º 6
0
    def test1ParameterAccess(self):
        """Test proper behavior of property access"""

        from AthExHelloWorld.AthExHelloWorldConf import HelloAlg

        HelloWorld = HelloAlg('test1ParameterAccess')

        # a not-yet-set variable should raise
        self.assertRaises(AttributeError, getattr, HelloWorld, 'MyInt')

        # a non-existing variable should raise
        self.assertRaises(AttributeError, setattr, HelloWorld, 'MyMy', 1)
Exemplo n.º 7
0
    def test2SetToolProperties(self):
        """Test setting of tool properties"""

        from AthExHelloWorld.AthExHelloWorldConf import HelloAlg
        from AthExHelloWorld.AthExHelloWorldConf import HelloTool

        HelloWorld = HelloAlg('HelloWorld')

        msg1 = "A Private Message!"

        HelloWorld.MyPrivateHelloTool = HelloTool("HelloTool")
        HelloWorld.MyPrivateHelloTool.MyMessage = msg1

        HelloWorld.setup()

        global ToolSvc

        msg2 = "A Public Message!"

        ToolSvc += HelloTool("PublicHello")
        ToolSvc.PublicHello.MyMessage = msg2

        ToolSvc.setup()

        self.assertEqual(HelloWorld.MyPrivateHelloTool.MyMessage, msg1)
        client = HelloWorld.getName(
        ) + '.' + HelloWorld.MyPrivateHelloTool.getName()
        self.assert_(JobOptionsSvc.verify(client, 'MyMessage', msg1))

        self.assertEqual(ToolSvc.PublicHello.MyMessage, msg2)
        self.assert_(
            JobOptionsSvc.verify('ToolSvc.PublicHello', 'MyMessage', msg2))
Exemplo n.º 8
0
    def test2ParameterValidation(self):
        """Test type checking of property setting"""

        from AthExHelloWorld.AthExHelloWorldConf import HelloAlg

        HelloWorld = HelloAlg('test2ParameterValidation')

        # not-allowed conversions
        self.assertRaises(ValueError, setattr, HelloWorld, 'MyInt', 1.)
        self.assertRaises(ValueError, setattr, HelloWorld, 'MyInt', '1')
        self.assertRaises(ValueError, setattr, HelloWorld, 'MyInt', [1])

        self.assertRaises(ValueError, setattr, HelloWorld, 'MyDouble', '1')
        self.assertRaises(ValueError, setattr, HelloWorld, 'MyDouble', '1.')
        self.assertRaises(ValueError, setattr, HelloWorld, 'MyDouble', [1.])
Exemplo n.º 9
0
#--------------------------------------------------------------

# Use McEventSelector so we can run with AthenaMP
import AthenaCommon.AtlasUnixGeneratorJob

#--------------------------------------------------------------
# Private Application Configuration options
#--------------------------------------------------------------

# Full job is a list of algorithms
from AthenaCommon.AlgSequence import AlgSequence
job = AlgSequence()

# Add top algorithms to be run
from AthExHelloWorld.AthExHelloWorldConf import HelloAlg
job += HelloAlg("HelloWorld")  # 1 alg, named "HelloWorld"

#--------------------------------------------------------------
# Set output level threshold (DEBUG, INFO, WARNING, ERROR, FATAL)
#--------------------------------------------------------------

# Output level for HelloAlg only (note name: instance, not type)
job.HelloWorld.OutputLevel = INFO

# You can set the global output level on the message svc (not
# recommended) or by using the -l athena CLI parameter

#--------------------------------------------------------------
# Event related parameters
#--------------------------------------------------------------
Exemplo n.º 10
0
    # Make MetaDataSvc an AddressProvider
    svcMgr.ProxyProviderSvc.ProviderNames += ["MetaDataSvc"]

    # enable IOVDbSvc to read metadata
    #svcMgr.MetaDataSvc.MetaDataContainer = "MetaDataHdr"
    #svcMgr.MetaDataSvc.MetaDataTools += [ "IOVDbMetaDataTool" ]

    MetaDataStore = svcMgr.MetaDataStore

#--------------------------------------------------------------
# Private Application Configuration options, replace with
# your configuration.
#--------------------------------------------------------------
from AthExHelloWorld.AthExHelloWorldConf import HelloAlg

HelloWorld = HelloAlg("HelloWorld")

from AthenaCommon.AlgSequence import AlgSequence
topSequence = AlgSequence()
topSequence += HelloWorld

#--------------------------------------------------------------
# Algorithms Private Options
#--------------------------------------------------------------

# For the genuine HelloWorld algorithm
HelloWorld.MyInt = 42
HelloWorld.MyBool = TRUE
HelloWorld.MyDouble = 3.14159
HelloWorld.MyStringVec = ["Welcome", "to", "Athena", "Framework", "Tutorial"]
Exemplo n.º 11
0
    def test1SetBuiltinTypes(self):
        """Test setting of builtin types"""

        from AthExHelloWorld.AthExHelloWorldConf import HelloAlg

        HelloWorld = HelloAlg('HelloWorld')

        HelloWorld.MyInt = 42
        HelloWorld.MyBool = True
        HelloWorld.MyDouble = 3.14159
        HelloWorld.MyStringVec = [
            "Welcome", "to", "Athena", "Framework", "Tutorial"
        ]
        HelloWorld.MyStringVec += ["!"]
        HelloWorld.MyDict = {
            'Bonjour': 'Guten Tag',
            'Good Morning': 'Bonjour',
            'one': 'uno'
        }
        HelloWorld.MyDict["Goeiedag"] = "Ni Hao"
        HelloWorld.MyTable = [(1, 1), (2, 4), (3, 9)]
        HelloWorld.MyTable += [(4, 16)]
        HelloWorld.MyMatrix = [[1, 2, 3], [4, 5, 6]]
        HelloWorld.MyMatrix += [[7, 8, 9]]

        HelloWorld.setup()

        self.assertEqual(HelloWorld.MyInt, 42)
        self.assert_(JobOptionsSvc.verify('HelloWorld', 'MyInt', '42'))

        self.assertEqual(HelloWorld.MyBool, True)
        self.assert_(JobOptionsSvc.verify('HelloWorld', 'MyBool', 'True'))

        self.assertEqual(round(HelloWorld.MyDouble - 3.14159, 8), 0.)
        self.assert_(JobOptionsSvc.verify('HelloWorld', 'MyDouble', '3.14159'))

        # the following may be too sensitive to non-consequential changes in formatting
        self.assertEqual(
            HelloWorld.MyStringVec,
            ["Welcome", "to", "Athena", "Framework", "Tutorial", "!"])
        self.assert_(
            JobOptionsSvc.verify(
                'HelloWorld', 'MyStringVec',
                "['Welcome', 'to', 'Athena', 'Framework', 'Tutorial', '!']"))

        self.assertEqual(
            HelloWorld.MyDict, {
                'Bonjour': 'Guten Tag',
                'one': 'uno',
                'Goeiedag': 'Ni Hao',
                'Good Morning': 'Bonjour'
            })
        self.assert_(
            JobOptionsSvc.verify(
                'HelloWorld', 'MyDict',
                "{'Bonjour': 'Guten Tag', 'one': 'uno', 'Goeiedag': 'Ni Hao', 'Good Morning': 'Bonjour'}"
            ))
        self.assertEqual(HelloWorld.MyTable, [(1, 1), (2, 4), (3, 9), (4, 16)])
        self.assert_(
            JobOptionsSvc.verify('HelloWorld', 'MyTable',
                                 "[(1, 1), (2, 4), (3, 9), (4, 16)]"))

        self.assertEqual(HelloWorld.MyMatrix,
                         [[1, 2, 3], [4, 5, 6], [7, 8, 9]])
        self.assert_(
            JobOptionsSvc.verify('HelloWorld', 'MyMatrix',
                                 "[[1, 2, 3], [4, 5, 6], [7, 8, 9]]"))
Exemplo n.º 12
0
   def test1SetBuiltinTypes( self ):
      """Test setting of builtin types"""

      from AthExHelloWorld.AthExHelloWorldConf import HelloAlg

      HelloWorld = HelloAlg( 'HelloWorld' )

      HelloWorld.MyInt = 42
      HelloWorld.MyBool = True
      HelloWorld.MyDouble = 3.14159
      HelloWorld.MyStringVec = [ "Welcome", "to", "Athena", "Framework", "Tutorial" ]
      HelloWorld.MyStringVec += [ "!" ]
      HelloWorld.MyDict = { 'Bonjour'      : 'Guten Tag',
                            'Good Morning' : 'Bonjour' , 'one' : 'uno' }
      HelloWorld.MyDict[ "Goeiedag" ] = "Ni Hao"
      HelloWorld.MyTable = [ ( 1 , 1 ) , ( 2 , 4 ) , ( 3 , 9 ) ]
      HelloWorld.MyTable += [ ( 4, 16 ) ]
      HelloWorld.MyMatrix = [ [ 1, 2, 3 ],
                              [ 4, 5, 6 ] ]
      HelloWorld.MyMatrix += [ [ 7, 8, 9 ] ]

      HelloWorld.setup()

      self.assertEqual( HelloWorld.MyInt, 42 )
      self.assert_( JobOptionsSvc.verify( 'HelloWorld', 'MyInt', '42' ) )

      self.assertEqual( HelloWorld.MyBool, True )
      self.assert_( JobOptionsSvc.verify( 'HelloWorld', 'MyBool', 'True' ) )

      self.assertEqual( round( HelloWorld.MyDouble - 3.14159, 8 ), 0. )
      self.assert_( JobOptionsSvc.verify( 'HelloWorld', 'MyDouble', '3.14159' ) )

    # the following may be too sensitive to non-consequential changes in formatting
      self.assertEqual( HelloWorld.MyStringVec,
         [ "Welcome", "to", "Athena", "Framework", "Tutorial", "!" ] )
      self.assert_( JobOptionsSvc.verify( 'HelloWorld', 'MyStringVec',
         "['Welcome', 'to', 'Athena', 'Framework', 'Tutorial', '!']" ) )

      self.assertEqual( HelloWorld.MyDict,
         {'Bonjour': 'Guten Tag', 'one': 'uno', 'Goeiedag': 'Ni Hao', 'Good Morning': 'Bonjour'} )
      self.assert_( JobOptionsSvc.verify( 'HelloWorld', 'MyDict',
         "{'Bonjour': 'Guten Tag', 'one': 'uno', 'Goeiedag': 'Ni Hao', 'Good Morning': 'Bonjour'}" ) )
      self.assertEqual( HelloWorld.MyTable, [(1, 1), (2, 4), (3, 9), (4, 16)] )
      self.assert_( JobOptionsSvc.verify( 'HelloWorld', 'MyTable',
         "[(1, 1), (2, 4), (3, 9), (4, 16)]" ) )

      self.assertEqual( HelloWorld.MyMatrix, [[1, 2, 3], [4, 5, 6], [7, 8, 9]] )
      self.assert_( JobOptionsSvc.verify( 'HelloWorld', 'MyMatrix',
         "[[1, 2, 3], [4, 5, 6], [7, 8, 9]]" ) )