|
101 | 101 | "+--------------------------------------+--------+--------------------+---------------------------+---------------+---------------+-----------------------------------------+\n", |
102 | 102 | "| id | flag | flag description | description | target_type | target_name | func |\n", |
103 | 103 | "|--------------------------------------+--------+--------------------+---------------------------+---------------+---------------+-----------------------------------------|\n", |
104 | | - "| 258da4da-f080-404a-bfdc-2faa6b32e60b | 1 | SUCCESSFUL | String dataset must be 1D | Group | tmp0.hdf | h5rdmtoolbox.database.hdfdb.filedb.find |\n", |
| 104 | + "| 39344777-7032-4f34-9f1f-ad14989430f5 | 1 | SUCCESSFUL | String dataset must be 1D | Group | tmp0.hdf | h5rdmtoolbox.database.hdfdb.filedb.find |\n", |
105 | 105 | "+--------------------------------------+--------+--------------------+---------------------------+---------------+---------------+-----------------------------------------+\n", |
106 | 106 | "--> Layout is valid\n" |
107 | 107 | ] |
|
142 | 142 | "re.search('^(?!S).*', 'M123')" |
143 | 143 | ] |
144 | 144 | }, |
| 145 | + { |
| 146 | + "cell_type": "markdown", |
| 147 | + "id": "6d8709ac-3676-4a56-891a-832deca11db4", |
| 148 | + "metadata": {}, |
| 149 | + "source": [ |
| 150 | + "## Defining RDF specifications\n", |
| 151 | + "\n", |
| 152 | + "All dataset must have the attribute units, which shall be semantically described by `http://w3id.org/nfdi4ing/metadata4ing#hasUnit`" |
| 153 | + ] |
| 154 | + }, |
| 155 | + { |
| 156 | + "cell_type": "code", |
| 157 | + "execution_count": 8, |
| 158 | + "id": "b6bda83f-582e-48d0-a9dc-7b8fc0576520", |
| 159 | + "metadata": {}, |
| 160 | + "outputs": [], |
| 161 | + "source": [ |
| 162 | + "rdf_lay = layout.Layout()" |
| 163 | + ] |
| 164 | + }, |
| 165 | + { |
| 166 | + "cell_type": "code", |
| 167 | + "execution_count": 9, |
| 168 | + "id": "a98ad451-b361-4f62-a24e-bc6840f9ae2f", |
| 169 | + "metadata": {}, |
| 170 | + "outputs": [], |
| 171 | + "source": [ |
| 172 | + "is_dataset = rdf_lay.add(\n", |
| 173 | + " hdfdb.FileDB.find,\n", |
| 174 | + " flt={'units': {'$exists': True}},\n", |
| 175 | + " recursive=True,\n", |
| 176 | + " objfilter='dataset',\n", |
| 177 | + " description='String dataset must be 1D',\n", |
| 178 | + " n={'$gt': 0}\n", |
| 179 | + ")" |
| 180 | + ] |
| 181 | + }, |
| 182 | + { |
| 183 | + "cell_type": "code", |
| 184 | + "execution_count": 10, |
| 185 | + "id": "edbd9a8f-03a0-41e8-b954-a97b1b5d180c", |
| 186 | + "metadata": {}, |
| 187 | + "outputs": [], |
| 188 | + "source": [ |
| 189 | + "from h5rdmtoolbox.database import rdf_find" |
| 190 | + ] |
| 191 | + }, |
| 192 | + { |
| 193 | + "cell_type": "code", |
| 194 | + "execution_count": 11, |
| 195 | + "id": "515b96d8-9025-4696-a5d7-6a2d0bc996f4", |
| 196 | + "metadata": {}, |
| 197 | + "outputs": [], |
| 198 | + "source": [ |
| 199 | + "is_dataset = is_dataset.add(\n", |
| 200 | + " rdf_find,\n", |
| 201 | + " rdf_predicate=\"http://w3id.org/nfdi4ing/metadata4ing#hasUnit\",\n", |
| 202 | + " n=1\n", |
| 203 | + ")" |
| 204 | + ] |
| 205 | + }, |
| 206 | + { |
| 207 | + "cell_type": "markdown", |
| 208 | + "id": "89fb9a00-eb31-42cf-9de1-e6e9785499b8", |
| 209 | + "metadata": {}, |
| 210 | + "source": [ |
| 211 | + "Test the layout specification" |
| 212 | + ] |
| 213 | + }, |
| 214 | + { |
| 215 | + "cell_type": "code", |
| 216 | + "execution_count": 16, |
| 217 | + "id": "4605bae5-fca9-4e0f-9249-cb77c05aab2a", |
| 218 | + "metadata": {}, |
| 219 | + "outputs": [], |
| 220 | + "source": [ |
| 221 | + "with h5tbx.File() as h5:\n", |
| 222 | + " ds =h5.create_dataset('velocity', data=4.5, attrs={'units': 'm/s'})" |
| 223 | + ] |
| 224 | + }, |
| 225 | + { |
| 226 | + "cell_type": "code", |
| 227 | + "execution_count": 17, |
| 228 | + "id": "83cd6254-f597-4dad-b281-7a594a0aec83", |
| 229 | + "metadata": {}, |
| 230 | + "outputs": [ |
| 231 | + { |
| 232 | + "name": "stderr", |
| 233 | + "output_type": "stream", |
| 234 | + "text": [ |
| 235 | + "2024-06-23_15:25:31,621 ERROR [core.py:330] Applying spec. \"LayoutSpecification(kwargs={'rdf_predicate': 'http://w3id.org/nfdi4ing/metadata4ing#hasUnit'})\" failed due to not matching the number of results: 1 != 0\n" |
| 236 | + ] |
| 237 | + }, |
| 238 | + { |
| 239 | + "data": { |
| 240 | + "text/plain": [ |
| 241 | + "False" |
| 242 | + ] |
| 243 | + }, |
| 244 | + "execution_count": 17, |
| 245 | + "metadata": {}, |
| 246 | + "output_type": "execute_result" |
| 247 | + } |
| 248 | + ], |
| 249 | + "source": [ |
| 250 | + "rdf_lay.validate(h5.hdf_filename).is_valid()" |
| 251 | + ] |
| 252 | + }, |
| 253 | + { |
| 254 | + "cell_type": "code", |
| 255 | + "execution_count": 18, |
| 256 | + "id": "bb359f6d-929e-46fa-a9c6-6c33e38658a3", |
| 257 | + "metadata": {}, |
| 258 | + "outputs": [], |
| 259 | + "source": [ |
| 260 | + "with h5tbx.File() as h5:\n", |
| 261 | + " ds =h5.create_dataset('velocity', data=4.5, attrs={'units': 'm/s'})\n", |
| 262 | + " ds.rdf['units'].predicate = \"http://w3id.org/nfdi4ing/metadata4ing#hasUnit\"" |
| 263 | + ] |
| 264 | + }, |
| 265 | + { |
| 266 | + "cell_type": "code", |
| 267 | + "execution_count": 19, |
| 268 | + "id": "264024ed-44a5-40ad-b2da-1075c7a58c69", |
| 269 | + "metadata": {}, |
| 270 | + "outputs": [ |
| 271 | + { |
| 272 | + "data": { |
| 273 | + "text/plain": [ |
| 274 | + "True" |
| 275 | + ] |
| 276 | + }, |
| 277 | + "execution_count": 19, |
| 278 | + "metadata": {}, |
| 279 | + "output_type": "execute_result" |
| 280 | + } |
| 281 | + ], |
| 282 | + "source": [ |
| 283 | + "rdf_lay.validate(h5.hdf_filename).is_valid()" |
| 284 | + ] |
| 285 | + }, |
145 | 286 | { |
146 | 287 | "cell_type": "code", |
147 | 288 | "execution_count": null, |
148 | | - "id": "95ff9f7c-2f9d-4552-bdad-7139e4ea445d", |
| 289 | + "id": "6d93fd9a-8df5-413a-ad92-23021ae8fc19", |
149 | 290 | "metadata": {}, |
150 | 291 | "outputs": [], |
151 | 292 | "source": [] |
|
0 commit comments