Overview# ro-crate-py is a Python library for creating and consuming Research Object Crates (RO-Crate) .
https://doi.org/10.5281/zenodo.3956493
ro-crate-py is a Python library to create and consume Research Object Crates. It currently supports the RO-Crate 1.1 specification.
Goal# The goal is to create a page like the one shown below.
https://nakamura196.github.io/rocrate_demo/crate/test/data/ro-crate-preview.html
Dataset Page#
Specific Item Page#
JSON Data# Create JSON data like the following.
https://nakamura196.github.io/rocrate_demo/crate/test/data/ro-crate-metadata.json
The item IDs are based on the following OAI-PMH record.
https://da.dl.itc.u-tokyo.ac.jp/portal/oai?verb=GetRecord&metadataPrefix=dcndl_simple&identifier=oai:da.dl.itc.u-tokyo.ac.jp:fbd0479b-dbb4-4eaa-95b8-f27e1c423e4b
As the item creator, a dummy ORCID ID is specified.
https://orcid.org/0000-0001-8245-7925
As the data publisher, the University of Tokyo’s Research Organization Registry (ROR) is specified.
https://ror.org/057zh3y96
Installing Libraries# bagit is not required by rocrate, but it is used here to output the final result in bagit format.
p p i i p p i i n n s s t t a a l l l l r b o a c g r i a t t e
f f f i i i i r r r m m m m o o o p p p p m m m o o o o r r r r r r r t t t t o o o c c c o b s j r r r s a h s a a a g u o t t t i t n e e e t i . . . l r m m o o o c d d r e e a l l t . . e p c e o i r n m s t p o e o n x r t t i e m n R p t O o i C r t r t y a t P i e e m r p s o o r n t C o n t e x t E n t i t y
Data# d d d i i i i p p o o a a a t t t t e e r r t t t e e e e r r g g a a a m m m m s s _ _ s s s _ _ _ _ o o i n e e e i n d l n n d a t t t d a e i _ _ m _ _ _ m s c i n = e n d l = e c e d a a e i r n m " = m s c " = i s = e h e c e h p e t " r n t " t " = t T = i s t 百 i = h p h p e p 鬼 o t " s e " t s 夜 n " t S : 百 i = : 行 h p a / U 鬼 o / 図 = t s t / n 夜 n " / " t : r i 行 h d " p r o v 図 = t a O s u r e コ t . A : o . r レ " p d I / r N o s ク 百 s l - / c a r i シ 鬼 : . P w i k g t ョ 夜 / i M w d a / y ン 行 / t H w . m 0 " 図 w c ( . o u 5 o ( w . O l r r 7 f ひ w u p i g a z や . - e b / " h T つ l t n . 0 3 o き i o u 0 y k や b k A - 0 9 y ぎ . y r t 0 6 o う u o c o - " " ず - . h k 0 ) t a i y 0 o c v o 0 蔭 k . e . 1 山 y j s a - 源 o p c 8 広 . / I . 2 迢 a p n j 4 写 c o i p 5 . r t / - 百 j t i j 7 鬼 p a a a 9 夜 / l t / 2 行 j / i l 5 は a o v i " 今 / a e b 昔 l i r 物 i ? P a 語 b v r r な r e o y ど a r t の r b c 説 y = c o 話 / G o n に c e l t で o t e て n R f n く t e o t る e c r s 言 n o / 葉 t r M a で s d e r 、 / & t c 京 a m a h の r e d i 大 c t a v 路 h a t e を i d a s 夜 v a - な e t H t 夜 s a a o な - P r p 化 t r v / け o e e r 物 p f s e た / i t u ち r x i s が e = n e 練 u d g " り s c ) 歩 e n " く " d 様 l 子 _ を s 表 i し m て p い l る e 。 & " i d e n t i f i e r = o a i : d a . d l . i t c . u - t o k y o . a c . j p : f b d 0 4 7 9 b - d b b 4 - 4 e a a - 9 5 b 8 - f 2 7 e 1 c 4 2 3 e 4 b " Creating an ROCrate Instance# By setting gen_preview=True, a preview.html file is also generated when saving.
c r a t e = R O C r a t e ( g e n _ p r e v i e w = T r u e )
r r r r o o o o o o o o t t t t _ _ _ _ d d d d a a a a t t t t a a a a s s s s e e e e t t t t [ [ [ = " " " n d l c a e i r m s c a e c e t " r n e ] i s . p e r = t " o i ] o d o t a n = _ t " d a ] d a s a t e = t a t a s _ d s e n a e t a t t m a _ e s l e i t c _ e d n e s s e c r i p t i o n
Creating Items# This time, we add remote entities.
https://github.com/ResearchObject/ro-crate-py?tab=readme-ov-file#adding-remote-entities
i } t ) e m " " " = n d l a e i c m s c r e c e a " r n t : i s e p e . i t " a t i : d e o d m n i _ _ " t f n : e i a m l m i _ e e t l ( , e i i m c t _ e e d n m e s _ s e i c d r , i p p t r i o o p n e , r t i e s = {
Adding a Creator# p c e r r a s t o " e n n . a a = m d e d P " ( e : p r e s p r o e s n r o ( s n c o ) r n a _ t n e a , m e p } e ) r s o n _ i d , p r o p e r t i e s = {
Add the Person as the item creator.
i t e m [ " a u t h o r " ] = p e r s o n
Adding a Publishing Organization# c l a s s d d e e O f f r g s _ v } r a _ u e a e n i p m l t i n e p u z i r t = " " r a t ( y @ @ n t _ O ( { i t i _ r s d y v o ( g e " p a n s a l : e l ( e n f " C l i ) s : o f z : e n , a l ' t t f O e c i . r x r o i g t a n d a E t , , n n e i t , s z i e a t i l t y d f i ) e ) o : n . n t _ ' i _ f i i n e i r t = _ N _ o ( n c e r , a t p e r , o p i e d r e t n i t e i s f = i N e o r n , e ) p : r o p e r t i e s ) o c r r g a t = " e n . O a a r m d g e d a " ( n : o i r z o g a r ) t g i _ o n n a ( m c e r } a ) t e , o r g _ i d , p r o p e r t i e s = {
f f f i i i i r r r m m m m o o o p p p p m m m o o o o r r r r r r r t t t t o o o c c c o b s j r r r s a h s a a a g u o t t t i t n e e e t i . . . l r m m o o o c d d r e e a l l t . . e p c e o i r n m s t p o e o n x r t t i e m n R p t O o i C r t r t y a t P i e e m r p s o o r n t C o n t e x t E n t i t y
Output# Here, the output directory is set to docs/crate/test.
f f f i i i i r r r m m m m o o o p p p p m m m o o o o r r r r r r r t t t t o o o c c c o b s j r r r s a h s a a a g u o t t t i t n e e e t i . . . l r m m o o o c d d r e e a l l t . . e p c e o i r n m s t p o e o n x r t t i e m n R p t O o i C r t r t y a t P i e e m r p s o o r n t C o n t e x t E n t i t y
You can also save a compressed file using write_zip.
f f f i i i i r r r m m m m o o o p p p p m m m o o o o r r r r r r r t t t t o o o c c c o b s j r r r s a h s a a a g u o t t t i t n e e e t i . . . l r m m o o o c d d r e e a l l t . . e p c e o i r n m s t p o e o n x r t t i e m n R p t O o i C r t r t y a t P i e e m r p s o o r n t C o n t e x t E n t i t y
Japanese Language Support# By default, Japanese characters are escaped, so set ensure_ascii to False.
f f f i i i i r r r m m m m o o o p p p p m m m o o o o r r r r r r r t t t t o o o c c c o b s j r r r s a h s a a a g u o t t t i t n e e e t i . . . l r m m o o o c d d r e e a l l t . . e p c e o i r n m s t p o e o n x r t t i e m n R p t O o i C r t r t y a t P i e e m r p s o o r n t C o n t e x t E n t i t y
Creating bagit# f f f i i i i r r r m m m m o o o p p p p m m m o o o o r r r r r r r t t t t o o o c c c o b s j r r r s a h s a a a g u o t t t i t n e e e t i . . . l r m m o o o c d d r e e a l l t . . e p c e o i r n m s t p o e o n x r t t i e m n R p t O o i C r t r t y a t P i e e m r p s o o r n t C o n t e x t E n t i t y
Supplement# For creating preview.html, you can use ROCrate(gen_preview=True), but by using the following module, you can create a preview.html like the one introduced at the beginning of this article.
f f f i i i i r r r m m m m o o o p p p p m m m o o o o r r r r r r r t t t t o o o c c c o b s j r r r s a h s a a a g u o t t t i t n e e e t i . . . l r m m o o o c d d r e e a l l t . . e p c e o i r n m s t p o e o n x r t t i e m n R p t O o i C r t r t y a t P i e e m r p s o o r n t C o n t e x t E n t i t y
Summary# I hope this is helpful for using RO-Crate.