本文整理汇总了Python中drslib.drs_tree.DRSTree类的典型用法代码示例。如果您正苦于以下问题:Python DRSTree类的具体用法?Python DRSTree怎么用?Python DRSTree使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了DRSTree类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_1
def test_1(self):
dt = DRSTree(self.tmpdir)
dt.discover(self.incoming, activity='cmip5',
product='output1', institute='MOHC', model='HadCM3')
assert len(dt.pub_trees) == 2
assert set([x.drs.realm for x in dt.pub_trees.values()]) == set(['atmos', 'ocean'])
示例2: TestListing
class TestListing(TestEg):
# Set the following in subclasses
# listing_file
def setUp(self):
super(TestListing, self).setUp()
listing_path = os.path.join(test_dir, self.listing_file)
gen_drs.write_listing(self.tmpdir, listing_path)
self._init_drs_fs()
self.dt = DRSTree(self.drs_fs)
def _init_drs_fs(self):
self.drs_fs = CMIP5FileSystem(self.tmpdir)
def _discover(self, institute, model):
self.dt.discover(self.incoming, activity='cmip5',
product='output1',
institute=institute,
model=model)
def _do_version(self, pt):
assert pt.state == pt.STATE_INITIAL
pt.do_version()
assert pt.state == pt.STATE_VERSIONED
assert pt.versions.keys() == [self.today]
示例3: TestRepair2
class TestRepair2(TestRepair):
genfuncs = (gen_drs.write_eg3_1, gen_drs.write_eg3_2)
def setUp(self):
TestEg.setUp(self)
self._cmor1()
self.pt.do_version(20100101)
self._cmor2()
self.pt.do_version(20100102)
assert self.pt.state == self.pt.STATE_VERSIONED
self.breakme()
def _cmor1(self):
genfunc = self.genfuncs[0]
genfunc(self.tmpdir)
self.dt = DRSTree(self.tmpdir)
self.dt.discover(self.incoming, activity='cmip5',
product='output1', institute='MOHC', model='HadCM3')
(self.pt, ) = self.dt.pub_trees.values()
def _cmor2(self):
genfunc = self.genfuncs[1]
genfunc(self.tmpdir)
self.dt.discover_incoming(self.incoming, activity='cmip5',
product='output1')
示例4: TestEg4
class TestEg4(TestEg3):
__test__ = True
def _cmor1(self):
gen_drs.write_eg4_1(self.tmpdir)
self.dt = DRSTree(self.tmpdir)
self.dt.discover(self.incoming, activity='cmip5',
product='output1', institute='MOHC', model='HadCM3')
(self.pt, ) = self.dt.pub_trees.values()
def _cmor2(self):
gen_drs.write_eg4_2(self.tmpdir)
self.dt.discover_incoming(self.incoming, activity='cmip5',
product='output1')
def test_1(self):
self._cmor1()
self.pt.do_version(20100101)
self._cmor2()
self.pt.do_version(20100102)
assert self._exists('files')
assert self._exists('files/tas_20100102')
assert self._exists('v20100102/tas')
def test_2(self):
self._cmor1()
self.pt.do_version(20100101)
self._cmor2()
self.pt.do_version(20100102)
assert len(self._listdir('files/tas_20100101')) == 3
assert len(self._listdir('files/tas_20100102')) == 2
assert len(self._listdir('v20100101/tas')) == 3
assert len(self._listdir('v20100102/tas')) == 5
# Do test_3 from superclass
# Do test_4 from superclass
def test_6(self):
# Test differencing 2 versions
self._cmor1()
self.pt.do_version(20100101)
self._cmor2()
v1 = []
todo = []
for state, path1, path2 in self.pt.diff_version(20100101):
if state == self.pt.DIFF_V1_ONLY:
v1.append(path1)
elif state == self.pt.DIFF_V2_ONLY:
todo.append(path2)
assert len(v1) == 3
assert len(todo) == 2
示例5: setUp
def setUp(self):
super(TestRepair, self).setUp()
gen_drs.write_listing(self.tmpdir, op.join(test_dir, self.listing))
dt = DRSTree(self.tmpdir)
dt.discover(self.incoming, **self.drs_components)
self.pt = dt.pub_trees.values()[0]
示例6: test_2
def test_2(self):
dt = DRSTree(self.tmpdir)
dt.discover(self.incoming, activity='cmip5',
product='output1', institute='MOHC', model='HadCM3')
assert len(dt.pub_trees) == 3
pt = dt.pub_trees.values()[0]
assert pt.drs.realm == 'atmos'
示例7: test_1
def test_1(self):
drs_fs = CordexFileSystem(self.tmpdir)
drs_tree = DRSTree(drs_fs)
json_obj = json.load(open(op.join(test_dir, 'cordex_1.json')))
drs_tree.discover_incoming_fromjson(json_obj, activity='cordex')
assert len(drs_tree.pub_trees) == 3
示例8: TestEg5
class TestEg5(TestEg4):
__test__ = False
def _cmor1(self):
gen_drs.write_eg5_1(self.tmpdir)
self.dt = DRSTree(self.tmpdir)
self.dt.discover(self.incoming, activity='cmip5',
product='output1', institute='MOHC', model='HadCM3')
(self.pt, ) = self.dt.pub_trees.values()
def _cmor2(self):
gen_drs.write_eg5_2(self.tmpdir)
self.dt.discover_incoming(self.incoming, activity='cmip5',
product='output1')
# Do test1 from superclass
def test_2(self):
self._cmor1()
self.pt.do_version(20100101)
self._cmor2()
self.pt.do_version(20100102)
assert len(self._listdir('files/tas_20100101')) == 5
assert len(self._listdir('files/tas_20100102')) == 2
assert len(self._listdir('v20100101/tas')) == 5
assert len(self._listdir('v20100102/tas')) == 5
# Do test_3 from superclass
# Do test_4 from superclass
def test_6(self):
# Test differencing 2 versions
self._cmor1()
self.pt.do_version(20100101)
self._cmor2()
v1 = []
todo = []
diff = []
same = []
for state, path1, path2 in self.pt.diff_version(20100101):
if state == self.pt.DIFF_V1_ONLY:
v1.append(path1)
elif state == self.pt.DIFF_V2_ONLY:
todo.append(path2)
elif state == self.pt.DIFF_SIZE:
diff.append(path1)
elif state == self.pt.DIFF_NONE:
same.append(path1)
#!TODO: not same? This test needs reviewing.
assert len(v1) == 3
assert len(same) == 2
示例9: TestEg5_1
class TestEg5_1(TestEg5):
__test__ = False
def _cmor2(self):
gen_drs.write_eg5_2(self.tmpdir)
self.dt2 = DRSTree(self.tmpdir)
self.dt2.discover_incoming(self.incoming, activity='cmip5',
product='output1')
(self.pt, ) = self.dt2.pub_trees.values()
示例10: setUp
def setUp(self):
super(TestMapfile, self).setUp()
gen_drs.write_eg1(self.tmpdir)
dt = DRSTree(self.tmpdir)
dt.discover(self.incoming, activity='cmip5',
product='output1', institute='MOHC', model='HadCM3')
self.pt = dt.pub_trees.values()[0]
self.pt.do_version()
assert self.pt.state == self.pt.STATE_VERSIONED
示例11: TestThreeway
class TestThreeway(TestEg):
__test__ = True
listing_files = ['threeway_1.ls', 'threeway_2.ls', 'threeway_3.ls']
def setUp(self):
super(TestThreeway, self).setUp()
self.drs_fs = CMIP5FileSystem(self.tmpdir)
self.dt = DRSTree(self.drs_fs)
self.listing_iter = self._iterSetUpListings()
def _iterSetUpListings(self):
for listing_file in self.listing_files:
listing_path = os.path.join(test_dir, listing_file)
gen_drs.write_listing(self.tmpdir, listing_path)
yield listing_path
def _discover(self):
self.dt.discover_incoming(self.incoming, activity='cmip5',
product='output1',
institute='MOHC',
model='HadGEM2-ES')
def _do_version(self, pt, next_version):
assert next_version not in pt.versions.keys()
pt.do_version(next_version)
assert next_version in pt.versions.keys()
def _check_version(self, pt, version):
for path, drs in pt.versions[version]:
assert os.path.islink(path)
# link is relative
real_path = os.path.realpath(os.path.join(os.path.dirname(path),
os.readlink(path)))
assert os.path.isfile(real_path)
# Check variables match
mo = re.search(r'/files/(.*?)_\d+/(.*?)_', real_path)
assert mo.group(1) == mo.group(2)
def test1(self):
v = 1
for listing_path in self.listing_iter:
print 'Doing version %d' % v
self._discover()
assert len(self.dt.pub_trees) == 1
pt = self.dt.pub_trees.values()[0]
self._do_version(pt, v)
self._check_version(pt, v)
v += 1
示例12: test_3
def test_3(self):
dt = DRSTree(self.tmpdir)
dt.discover(self.incoming, activity='cmip5',
product='output1', institute='MOHC', model='HadCM3')
pt = dt.pub_trees.values()[0]
assert pt.state == pt.STATE_INITIAL
pt.do_version()
assert pt.state == pt.STATE_VERSIONED
assert len(pt.versions.keys()) == 1
assert self.today in pt.versions.keys()
示例13: TestEg3_1
class TestEg3_1(TestEg3):
"""Use a separate DRSTree instance for the upgrade to test
TestEg3 still works in this scenario.
"""
__test__ = True
def _cmor2(self):
gen_drs.write_eg3_2(self.tmpdir)
self.dt2 = DRSTree(self.tmpdir)
self.dt2.discover_incoming(self.incoming, activity='cmip5',
product='output1')
(self.pt, ) = self.dt2.pub_trees.values()
示例14: TestEmptyPubdir
class TestEmptyPubdir(TestEg):
# Regression for bug where drs_tool crashes if the PublishTree directory
# exists but is empty
__test__ = True
def setUp(self):
super(TestEmptyPubdir, self).setUp()
pubdir = op.join(self.tmpdir,
'output2/MOHC/HadGEM2-ES/esmControl/day/seaIce/day/r1i1p1')
os.makedirs(pubdir)
self.dt = DRSTree(self.tmpdir)
def test_1(self):
self.dt.discover()
示例15: setUp
def setUp(self):
super(TestEmptyPubdir, self).setUp()
pubdir = op.join(self.tmpdir,
'output2/MOHC/HadGEM2-ES/esmControl/day/seaIce/day/r1i1p1')
os.makedirs(pubdir)
self.dt = DRSTree(self.tmpdir)