本文整理汇总了Python中tardis.tardis_portal.models.Schema类的典型用法代码示例。如果您正苦于以下问题:Python Schema类的具体用法?Python Schema怎么用?Python Schema使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Schema类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: save_rif_cs_profile
def save_rif_cs_profile(self, experiment, profile):
"""
Save selected profile choice as experiment parameter
"""
namespace = "http://monash.edu.au/rif-cs/profile/"
schema = None
try:
schema = Schema.objects.get(
namespace__exact=namespace)
except Schema.DoesNotExist:
logger.debug('Schema ' + namespace +
' does not exist. Creating.')
schema = Schema(namespace=namespace)
schema.save()
parametername = ParameterName.objects.get(
schema__namespace__exact=schema.namespace,
name="profile")
parameterset = None
try:
parameterset = \
ExperimentParameterSet.objects.get(\
schema=schema,
experiment=experiment)
except ExperimentParameterSet.DoesNotExist, e:
parameterset = ExperimentParameterSet(\
schema=schema,
experiment=experiment)
parameterset.save()
示例2: get_schema
def get_schema(schema, name):
"""Return the schema object that the paramaterset will use.
"""
try:
return Schema.objects.get(namespace__exact=schema)
except Schema.DoesNotExist:
schema = Schema(namespace=schema, name=name, type=Schema.DATASET)
schema.save()
return schema
示例3: getSchema
def getSchema(self):
"""Returns the schema object that the parameter set will use.
"""
try:
return Schema.objects.get(namespace__exact=self.schema)
except Schema.DoesNotExist:
schema = Schema(namespace=self.schema, name=self.name, type=Schema.DATAFILE)
schema.save()
return schema
示例4: get_schema
def get_schema(self):
try:
schema = Schema.objects.get(
namespace=self.namespace)
except ObjectDoesNotExist:
schema = Schema()
schema.namespace = self.namespace
schema.save()
self.schema = schema
return schema
示例5: get_schema
def get_schema(self):
from tardis.tardis_portal.models import Schema
try:
schema = Schema.objects.get(
namespace=self.namespace)
except ObjectDoesNotExist:
schema = Schema()
schema.namespace = self.namespace
schema.save()
self.schema = schema
return schema
示例6: getSchema
def getSchema(self):
"""Return the schema object that the paramaterset will use.
"""
logger.error('Olympus-getSchema()')
try:
return Schema.objects.get(namespace__exact=self.schema)
except Schema.DoesNotExist:
schema = Schema(namespace=self.schema, name=self.name,
type=Schema.DATAFILE)
schema.save()
return schema
示例7: setUp
def setUp(self):
# Load schemas for test
from django.core.management import call_command
call_command('loaddata', 'as_schemas')
self.client = Client()
self.experiments = []
try:
user = User.objects.get(username='test')
except User.DoesNotExist:
user = User.objects.create_user('test', '', 'test')
user.save()
self.userprofile = user.userprofile
# base_path = path.abspath(path.dirname(__file__))
experiment = Experiment(title='SAXS Test',
created_by=user)
experiment.save()
acl = ObjectACL(pluginId=django_user,
entityId=str(user.id),
content_object=experiment,
canRead=True,
canWrite=True,
canDelete=True,
isOwner=True)
acl.save()
self.experiments += [experiment]
schema = Schema.objects.get(type=Schema.DATAFILE, subtype='saxs')
parameter = ParameterName.objects.get(schema=schema, name='io')
parameter.is_searchable = True
parameter.save()
self.io_param_name = parameter.getUniqueShortName()
schema = Schema.objects.get(type=Schema.DATASET, subtype='saxs')
parameter = ParameterName.objects.get(schema=schema, name='frqimn')
parameter.is_searchable = True
parameter.save()
self.frqimn_param_name = parameter.getUniqueShortName()
new_schema = Schema()
new_schema.namespace = 'testschemawithduplicatename'
new_schema.save()
new_param = ParameterName(
schema=new_schema,
name='title',
full_name='Duplicate title parametername',
is_searchable=True)
new_param.save()
示例8: _get_schema
def _get_schema(schema,name):
"""Return the schema object that the paramaterset will use.
"""
try:
sch = Schema.objects.get(namespace__exact=schema)
logger.debug("found %s %s" % (sch.namespace, sch.name))
return sch
except Schema.DoesNotExist:
schema = Schema(namespace=schema, name=name,
type=Schema.DATASET)
schema.save()
logger.debug("creating %s %s " % (schema,name))
return schema
示例9: getSchema
def getSchema(self):
return Schema.objects.get(namespace='http://cai.uq.edu.au/schema/metadata/1')
# FIXME Ignoring this stuff... why would we dynamically create a Schema here?
"""Return the schema object that the paramaterset will use.
"""
try:
return Schema.objects.get(namespace__exact=self.schema)
except Schema.DoesNotExist:
schema = Schema(namespace=self.schema, name=self.name,
type=Schema.DATAFILE)
schema.save()
return schema
示例10: setUp
def setUp(self):
"""
setting up essential objects, copied from tests above
"""
user = "tardis_user1"
pwd = "secret"
email = ""
self.user = User.objects.create_user(user, email, pwd)
self.userProfile = self.user.userprofile
self.exp = Experiment(title="test exp1", institution_name="monash", created_by=self.user)
self.exp.save()
self.acl = ObjectACL(
pluginId=django_user,
entityId=str(self.user.id),
content_object=self.exp,
canRead=True,
isOwner=True,
aclOwnershipType=ObjectACL.OWNER_OWNED,
)
self.acl.save()
self.dataset = Dataset(description="dataset description...")
self.dataset.save()
self.dataset.experiments.add(self.exp)
self.dataset.save()
self.datafile = DataFile(dataset=self.dataset, size=42, filename="foo", md5sum="junk")
self.datafile.save()
self.testschema = Schema(
namespace="http://test.com/test/schema", name="Test View", type=Schema.DATAFILE, hidden=True
)
self.testschema.save()
self.dfps = DatafileParameterSet(datafile=self.datafile, schema=self.testschema)
self.dfps.save()
示例11: _save_party_refs
def _save_party_refs(self, party, party_relation):
""" Save party and party relation information as parameters on the
experiment
"""
namespace = "http://rmit.edu.au/rif-cs/party/1.0/"
logger.debug("saving party")
schema = None
try:
schema = Schema.objects.get(
namespace__exact=namespace)
except Schema.DoesNotExist:
logger.debug('Schema ' + namespace +
' does not exist. Creating.')
schema = Schema(namespace=namespace)
schema.save()
exp = Experiment.objects.get(pk=self.experiment_id)
party_id_param = self._make_param(schema=schema,
name="party_id",
paramtype=ParameterName.NUMERIC)
relation_param = self._make_param(schema=schema,
name="relationtocollection_id",
paramtype=ParameterName.STRING)
parameterset = ExperimentParameterSet(schema=schema, experiment=exp)
parameterset.save()
ep = ExperimentParameter.objects.filter(name=party_id_param,
parameterset=parameterset,
parameterset__experiment=exp)
for p in ep:
p.delete()
ep = ExperimentParameter(
parameterset=parameterset,
name=party_id_param,
numerical_value=party.pk)
ep.save()
ep = ExperimentParameter.objects.filter(name=relation_param,
parameterset=parameterset,
parameterset__experiment=exp)
for p in ep:
p.delete()
ep = ExperimentParameter(
parameterset=parameterset,
name=relation_param,
string_value=party_relation)
ep.save()
示例12: test_contextual_view
def test_contextual_view(self):
"""
Given schema on dataset, check that image file created
"""
user = _create_test_user()
license = _create_license()
exp = _create_test_experiment(user, license)
ds = Dataset(description='happy snaps of plumage')
ds.save()
ds = _create_test_dataset(ds, exp.id, {
"output.dat": 'test data\n',
"grexp.dat": '1 2\n2 3\n3 7\n',
"grfinal21.dat": '1 2\n 2 4\n4 9\n'})
sch = Schema(namespace=self.HRMCSCHEMA,
name="hrmc_views", type=Schema.DATASET)
sch.save()
param = ParameterName(schema=sch, name="plot",
full_name="scatterplot", units="image",
data_type=ParameterName.FILENAME
)
param.save()
dps = DatasetParameterSet(schema=sch, dataset=ds)
dps.save()
ds.experiments.add(exp)
ds.save()
client = Client()
response = client.get('/dataset/%s' % ds.id)
self.assertEqual(response.status_code, 200)
param_sets = get_param_sets(ds)
self.assertTrue(param_sets)
dp = DatasetParameter.objects.get(parameterset=param_sets[0],
name=param)
self.assertTrue(dp)
self.assertNotEquals(dp.string_value, "") # ie, it has a filename
示例13: __getFilteredExperiments
def __getFilteredExperiments(request, searchFilterData):
"""Filter the list of experiments using the cleaned up searchFilterData.
Arguments:
request -- the HTTP request
searchFilterData -- the cleaned up search experiment form data
Returns:
A list of experiments as a result of the query or None if the provided
search request is invalid
"""
experiments = authz.get_accessible_experiments(request)
if experiments is None:
return []
# search for the default experiment fields
if searchFilterData['title'] != '':
experiments = \
experiments.filter(title__icontains=searchFilterData['title'])
if searchFilterData['description'] != '':
experiments = \
experiments.filter(
description__icontains=searchFilterData['description'])
if searchFilterData['institutionName'] != '':
experiments = experiments.filter(
institution_name__icontains=searchFilterData['institutionName'])
if searchFilterData['creator'] != '':
experiments = experiments.filter(
experimentauthor__author__icontains=searchFilterData['creator'])
date = searchFilterData['date']
if date is not None:
experiments = \
experiments.filter(start_time__lt=date, end_time__gt=date)
# get all the experiment parameters
exp_schema_namespaces = Schema.getNamespaces(Schema.EXPERIMENT)
parameters = ParameterName.objects.filter(
schema__namespace__in=exp_schema_namespaces, is_searchable=True)
experiments = __filterParameters(
parameters, experiments,
searchFilterData, 'experimentparameterset__experimentparameter')
# let's sort it in the end
experiments = experiments.order_by('title')
return experiments
示例14: test_hrmc_filter
def test_hrmc_filter(self):
"""
Make an experiment, lood up grexp file and check
dataset schema missing, then loadup grfinal and check dataset schema
created
"""
user = _create_test_user()
license = _create_license()
exp = _create_test_experiment(user, license)
ds = Dataset(description='happy snaps of plumage')
ds.save()
_create_test_dataset(ds, exp.id,
{"output.dat": 'hello', "grexp.dat": '2 5\n6 15\n'})
ds.experiments.add(exp)
ds.save()
sch = Schema(namespace=self.HRMCSCHEMA,
name="hrmc_views", type=Schema.DATASET)
sch.save()
param = ParameterName(schema=sch, name="plot",
full_name="scatterplot", units="image",
data_type=ParameterName.FILENAME
)
param.save()
param_sets = get_param_sets(ds)
self.assertEquals(list(param_sets), [])
_create_test_dataset(ds, exp.id, {'grfinal21.dat': "1 3\n5 14\n"})
df2 = Dataset_File(dataset=ds, url='path/grfinal21.dat')
df2.save()
h = hrmc.HRMCOutput('HRMC', self.HRMCSCHEMA)
h(sender=Dataset_File, instance=df2)
param_sets = get_param_sets(ds)
self.assertEquals([x.schema.namespace for x in param_sets],
[self.HRMCSCHEMA])
示例15: ParameterSetManagerTestCase
class ParameterSetManagerTestCase(TestCase):
def setUp(self):
from django.contrib.auth.models import User
from tempfile import mkdtemp
user = 'tardis_user1'
pwd = 'secret'
email = ''
self.user = User.objects.create_user(user, email, pwd)
self.test_dir = mkdtemp()
self.exp = Experiment(title='test exp1',
institution_name='monash',
created_by=self.user)
self.exp.save()
self.dataset = Dataset(description="dataset description...")
self.dataset.save()
self.dataset.experiments.add(self.exp)
self.dataset.save()
self.datafile = DataFile(dataset=self.dataset,
filename="testfile.txt",
size="42", md5sum='bogus')
self.datafile.save()
self.dfo = DataFileObject(
datafile=self.datafile,
storage_box=self.datafile.get_default_storage_box(),
uri="1/testfile.txt")
self.dfo.save()
self.schema = Schema(
namespace="http://localhost/psmtest/df/",
name="Parameter Set Manager", type=3)
self.schema.save()
self.parametername1 = ParameterName(
schema=self.schema, name="parameter1",
full_name="Parameter 1")
self.parametername1.save()
self.parametername2 = ParameterName(
schema=self.schema, name="parameter2",
full_name="Parameter 2",
data_type=ParameterName.NUMERIC)
self.parametername2.save()
self.parametername3 = ParameterName(
schema=self.schema, name="parameter3",
full_name="Parameter 3",
data_type=ParameterName.DATETIME)
self.parametername3.save()
self.datafileparameterset = DatafileParameterSet(
schema=self.schema, datafile=self.datafile)
self.datafileparameterset.save()
self.datafileparameter1 = DatafileParameter(
parameterset=self.datafileparameterset,
name=self.parametername1, string_value="test1")
self.datafileparameter1.save()
self.datafileparameter2 = DatafileParameter(
parameterset=self.datafileparameterset,
name=self.parametername2, numerical_value=2)
self.datafileparameter2.save()
# Create a ParameterName and Parameter of type LINK to an experiment
self.parametername_exp_link = ParameterName(
schema=self.schema, name="exp_link",
full_name="This parameter is a experiment LINK",
data_type=ParameterName.LINK)
self.parametername_exp_link.save()
self.exp_link_param = DatafileParameter(
parameterset=self.datafileparameterset,
name=self.parametername_exp_link)
exp_url = self.exp.get_absolute_url() # /experiment/view/1/
self.exp_link_param.set_value(exp_url)
self.exp_link_param.save()
# Create a ParameterName and Parameter of type LINK to a dataset
self.parametername_dataset_link = ParameterName(
schema=self.schema, name="dataset_link",
full_name="This parameter is a dataset LINK",
data_type=ParameterName.LINK)
self.parametername_dataset_link.save()
self.dataset_link_param = DatafileParameter(
parameterset=self.datafileparameterset,
name=self.parametername_dataset_link)
dataset_url = self.dataset.get_absolute_url() # /dataset/1/
self.dataset_link_param.set_value(dataset_url)
self.dataset_link_param.save()
# Create a ParameterName type LINK to an unresolvable (non-URL)
# free-text value
#.........这里部分代码省略.........