Open Metadata 0.3 ("Object")

28 views
Skip to first unread message

Marcus Ottosson

unread,
Apr 7, 2014, 3:09:25 PM4/7/14
to open-m...@googlegroups.com
Hi,

I'm happy to share with you a new update in regards to cascading information, such as supplemented or overridden environment settings, supported software or included scripts and plugins in specific assets or shots within a hierarchy; I'm calling it Object-oriented metadata.

Have a glance at the example and give it a spin.


Specification is here, although the implementation is newer and differs slightly.


Let me know what you think. :)

Best, 
Marcus

Marcus Ottosson

unread,
Apr 8, 2014, 2:49:31 AM4/8/14
to open-m...@googlegroups.com
As this is the absolute first thread here, I'll include some starter-content from the /samples directory of the repository.

From convenience.py, this is how you might work with Open Metadata if you weren't too interested in the internals, size of your output or performance.

"""


This module provides examples of Open Metadata convenience methods


Convenience methods are provided as a means of reading and writing
metadata where requirements in functionality and performance are low;
such as in debugging or one-off reading/writing.


"""



import os
import openmetadata as om


# Starting-point
path
= os.path.expanduser(r'~\om_temp')


if not os.path.exists(path):
    os
.mkdir(path)


om
.write(path, True, 'status')
om
.write(path, 'There once was a boy', 'story')
om
.write(path, 27, 'age')


data
= {
   
'firstname': 'Marcus',
   
'lastname': 'Ottosson',
   
'email': 'konstr...@gmail.com'
}


for key, value in data.iteritems():
    om
.write(path, value, key)


# Write deeply nested data
om
.write(path, True, 'root', 'group', 'amazing')


# Successfully wrote: c:\users\marcus\om2\.meta\status.bool
# Successfully wrote: c:\users\marcus\om2\.meta\story.string
# Successfully wrote: c:\users\marcus\om2\.meta\age.int
# Successfully wrote: c:\users\marcus\om2\.meta\lastname.string
# Successfully wrote: c:\users\marcus\om2\.meta\email.string
# Successfully wrote: c:\users\marcus\om2\.meta\firstname.string
# Successfully wrote: c:\users\marcus\om2\.meta\root\group\amazing.bool




From basic.py, provides an overview of how you may work with Open Metadata where you'd prefer greater control over the output, size and performance.

"""


This module provides basic examples for working with Open Metadata


"""



import os
import openmetadata as om


# Starting-point
path
= os.path.expanduser(r'~\om_temp')


if not os.path.exists(path):
    os
.mkdir(path)


location
= om.Location(path)


# Add a regular string
ostring
= om.Dataset('simple_data.string', parent=location)
ostring
.data = 'my simple string'


# Add a list
olist
= om.Group('mylist.list', parent=location)


# Containing three datasets..
l1
= om.Dataset(path='item1.string', data='a string value', parent=olist)
l2
= om.Dataset(path='item2.bool', data=True, parent=olist)
l3
= om.Dataset(path='item3.int', data=5, parent=olist)


# ..and a dictionary..
odict
= om.Group(path='mydict.dict', parent=olist)


# ..with two keys
key1
= om.Dataset('key1.string', data='value', parent=odict)


# One of which, we neglect to specify a data-type.
# The data-type will be determined via the Python data-type <str>
key2
= om.Dataset('key2', data='value', parent=odict)


# Finally, write it to disk.
om
.dump(location)




# ----------- Read it back in




# path = r'c:\users\marcus\om2'
print om.read(path)
# --> [List('mylist.list'), String('simple_data.string')]


print om.read(path, 'mylist')
# --> [Bool('item2.bool'), Int('item3.int'), ...]


print om.read(path, 'mylist', 'item2')
# # --> True


# assert om.read == om.listdir


for item in om.listdir(path):
   
print item.path
# # --> c:\users\marcus\om2\.meta\mylist.list
# --> c:\users\marcus\om2\.meta\simple_data.string

Reply all
Reply to author
Forward
0 new messages