from lsst.sims.catalogs.generation.db import JobId, JobState #Make a couple of ids... myid1 = JobId(10) myid2 = JobId(10, "simon") #make a couple of job states js = {} js["1"] = JobState(myid1) js["2"] = JobState(myid2) js["3"] = JobState() js["4"] = JobState(11) for k in js.keys(): js[k].updateState("Updating with key", "Key is %s" % k) js[k].updateState("Updating with another key", "Key is %s" % k) for k in js.keys(): js[k].showStates() js["1"].deleteStates() js["2"].deleteStates() js["3"].deleteStates() js["4"].deleteStates()
#!/usr/bin/env python from lsst.sims.catalogs.generation.db import LogEvents, JobState mj = LogEvents() js = JobState() mj.registerTaskStart() for i in range(100): if(i%5 == 0): mj.registerEvent("event%i"%(i/5), eventdescription="Done %i of %i"%(i,100)) mj.persist("MyFakeMetric", 1.0, "This is some sort of floating point value") mj.registerTaskStop() js.updateState("mykey","my value") print js.queryState("mykey") js.updateState("mykey","now my value") print js.queryState("mykey") js.updateState("newkey", "my new key") print js.queryState("newkey")
#!/usr/bin/env python import time from lsst.sims.catalogs.generation.db import JobId, JobState import sys if __name__ == "__main__": if len(sys.argv) == 1: jid = 77 owner = 'anon' elif len(sys.argv) == 2: jid = int(sys.argv[1]) owner = 'anon' elif len(sys.argv) == 3: jid = int(sys.argv[1]) owner = sys.argv[2] else: print "usage: python getStateList.py [jobid] [owner]" jobid = JobId(id=jid, owner=owner) js = JobState(jobid=jobid) states = js.showStates() print "***Printing all keys***" for k in states.keys(): print "%s %s" % (k, states[k])
#!/usr/bin/env python import time from lsst.sims.catalogs.generation.db import JobId, JobState import sys if __name__ == "__main__": if len(sys.argv) == 1: jid = 77 owner = 'anon' elif len(sys.argv) == 2: jid = int(sys.argv[1]) owner = 'anon' elif len(sys.argv) == 3: jid = int(sys.argv[1]) owner = sys.argv[2] else: print "usage: python getStateList.py [jobid] [owner]" jobid = JobId(id=jid, owner=owner) js = JobState(jobid=jobid) states = js.showStates() print "***Printing all keys***" for k in states.keys(): print "%s %s"%(k, states[k])
#!/usr/bin/env python from lsst.sims.catalogs.generation.db import JobId, JobState import sys if len(sys.argv) < 3: print "Usage jobstate_update_test.py jobid owner" sys.exit(1) id = int(sys.argv[1]) owner = sys.argv[2] jid = JobId(id, owner) js = JobState(jobid=jid) jobid = js.getJobId() print jobid print js.queryState("mykey") print js.queryState("newkey") js.updateState("mykey","value from second process") print js.queryState("mykey") js.updateState("newprocesskey", "brand new key/value from second process") print js.queryState("newprocesskey") print js.showStates()
#!/usr/bin/env python from lsst.sims.catalogs.generation.db import LogEvents, JobState mj = LogEvents() js = JobState() mj.registerTaskStart() for i in range(100): if (i % 5 == 0): mj.registerEvent("event%i" % (i / 5), eventdescription="Done %i of %i" % (i, 100)) mj.persist("MyFakeMetric", 1.0, "This is some sort of floating point value") mj.registerTaskStop() js.updateState("mykey", "my value") print js.queryState("mykey") js.updateState("mykey", "now my value") print js.queryState("mykey") js.updateState("newkey", "my new key") print js.queryState("newkey")
#!/usr/bin/env python from lsst.sims.catalogs.generation.db import JobState import sys js = JobState() jobid = js.getJobId() print jobid.getOwner(), jobid.getId() js.updateState("mykey", "my value") print js.queryState("mykey") js.updateState("mykey", "now my value") print js.queryState("mykey") js.updateState("newkey", "my new key") print js.queryState("newkey") print "***Printing all keys***" states = js.showStates() for k in states.keys(): print "%s %s" % (k, states[k]) jids = js.getJobIdsByOwner('anon') for jid in jids: print jid.getId()
#!/usr/bin/env python from lsst.sims.catalogs.generation.db import JobId, JobState import sys if len(sys.argv) < 3: print "Usage jobstate_update_test.py jobid owner" sys.exit(1) id = int(sys.argv[1]) owner = sys.argv[2] jid = JobId(id, owner) js = JobState(jobid=jid) jobid = js.getJobId() print jobid print js.queryState("mykey") print js.queryState("newkey") js.updateState("mykey", "value from second process") print js.queryState("mykey") js.updateState("newprocesskey", "brand new key/value from second process") print js.queryState("newprocesskey") print js.showStates()
#!/usr/bin/env python from lsst.sims.catalogs.generation.db import JobState import sys import time js = JobState() jobid = js.getJobId() print jobid.getId(), jobid.getOwner() js.updateState("mykey","my value") while True: print js.queryState("mykey") time.sleep(2)
#!/usr/bin/env python from lsst.sims.catalogs.generation.db import JobState import sys js = JobState() jobid = js.getJobId() print jobid.getOwner(), jobid.getId() js.updateState("mykey","my value") print js.queryState("mykey") js.updateState("mykey","now my value") print js.queryState("mykey") js.updateState("newkey", "my new key") print js.queryState("newkey") print "***Printing all keys***" states = js.showStates() for k in states.keys(): print "%s %s"%(k, states[k]) jids = js.getJobIdsByOwner('anon') for jid in jids: print jid.getId()
#!/usr/bin/env python from lsst.sims.catalogs.generation.db import JobState import sys import time js = JobState() jobid = js.getJobId() print jobid.getId(), jobid.getOwner() js.updateState("mykey", "my value") while True: print js.queryState("mykey") time.sleep(2)