Closed abrin closed 3 years ago
Thank you for the detailed test script - it made it easy to debug!
So the error isn't wrong - the file we get schema types from is called schema-types.csv, and that does not have a Collection
. If I look at the difference between the two, the file you reference has many more:
including Collection :) The structure of these files seems the same, but I'm not sure what distinguishes the two files. Could you ping folks at schema.org and figure out what the difference is between these two files? If it doesn't hurt to change to use the layers file (since it includes all of the other) then we can update to that. If it's not the right thing to do, then I can make a variable to let you choose the file. I'd also be curious about the other ext files that have types - are they included in the layers file? If we can find the "one file to rule them all" in terms of types, or at least an understanding of the difference, I'd be happy to make a PR to update the package so it works for your use case. Thank you!
Good Morning,
I took a closer look at the schema.org site and their releases and noticed that this repo is stopping at 7.03, but they're up to version 12.0
. It also looks like they may have deprecated the all-types file (see) because the schema-types file only has the core elements, if I'm reading the comment properly. is it possible to update to use the newer structure?
Thanks,
Adam
Yes definitely possible. I can possibly get to this on a weekend, and please feel free to do a PR with the new files first if you have the time!
hey! So I think I can make some time at the end of the work day to fix this up for you - I'll prepare a PR with the new version for you to test.
Give this a test out! https://github.com/openschemas/schemaorg/pull/35
I'm switching from CircleCI to GitHub actions, so ignore the CI results for now (I disconnected it).
Thanks!
Just tried and I'm getting:
ERROR /workspace/schemaorg/schemaorg/data/releases/12.0/schema-types.csv does not exist.
followed the install instructions from:
git clone https://www.github.com/openschemas/schemaorg
cd schemaorg
python setup.py install
Should it be reading schemaorg-current-http-types.csv
and schemaorg-current-http-properties.csv
instead of schema-properties.csv
and schema-types.csv
?
I tried making that change, but now I get:
Specification base set to http://www.schema.org
Using Version 12.0
Found http://www.schema.org/Collection
Collection: found 121 properties
Traceback (most recent call last):
File "test.py", line 13, in <module>
collection.validate(collection)
AttributeError: 'Schema' object has no attribute 'validate'
Make sure that you clone the branch in the linked PR (in your example you clone the main repository, which isn't different). And then self.collection.validate I don't believe was a supported function. The validation is done by the recipe parser, e.g.,
recipe = RecipeParser("recipe.yml")
Otherwise, the output looks good - I see that the Collection is found for version 12.0 with 121 properties!
Should it be reading schemaorg-current-http-types.csv and schemaorg-current-http-properties.csv instead of schema-properties.csv and schema-types.csv?
if you take a look at the changed code, you'll see we are using those files, just the https versions.
confirming I'm on the right branch. I'm wondering if schemaorg/data/__init__.py
needs to be changed? This is what got me from the previous error to the current error :
abrin@GT29036 schemaorg % git branch
* add/release-12.0
master
abrin@GT29036 schemaorg % python test.py
Specification base set to http://www.schema.org
Using Version 12.0
Found http://www.schema.org/Collection
Collection: found 121 properties
Traceback (most recent call last):
File "test.py", line 13, in <module>
collection.validate(collection)
AttributeError: 'Schema' object has no attribute 'validate'
Just not sure how to address that. Attached my two test files, which I've pulled out of the test (can't seem to get pytest to run them without a module error, and this seemed faster).
thanks
Sorry I'm not sure if you are hearing me - the Schema object does not have a validate funciton.
In your example, you would need to do:
collection = Schema('Collection')
recipe = RecipeParser("recipe.yml")
recipe.validate(collection)
Does that make sense?
Yes, that makes sense .Thanks for your patience with me, and apologies for the confusion and miss-understanding I caused. I tested with the correct validation code that I miss-entered. It works, but only with a change to these two lines:
reference to schema-properties in "schemaorg/schemaorg/data/init.py:90" and reference to schema-types.csv in "schemaorg/schemaorg/data/init.py:104"
@abrin that was my mistake! I had the changes locally and for some reason they didn't push. Please take another look!
That did it. My test works. thank you.
Great! Apologies for my oversight of not pushing the commits. I was testing different gpg keys yesterday and I think one of my commits just didn't take (and the other to add the new data was so large I didn't notice).
I'll get the PR merged and released asap.
Fixed with #35.
Describe the bug
Hi, I was able to find the definitions for a collection schema in the [csv] (https://raw.githubusercontent.com/openschemas/schemaorg/master/schemaorg/data/releases/7.03/all-layers-types.csv), and JSON-LD files, but when you try and use it, it's reported that it doesn't exist (here's the output of the test I created (below). Not sure I'm missing something though?:
To Reproduce Steps to reproduce the behavior:
I created a basic test:
recipe.yml
thanks Version of Python schemaorg latest