As discussed in today's pyDataverse meeting, @liujinjie111 and I are both seeing a "TypeError: issubclass() arg 1 must be a class" when trying to follow the "create dataset" docs at https://gdcc.github.io/pyDataverse/high-level/dataverse/
I'm on this commit: 7f56e21
I've narrowed it down to this line, where I've added a comment locally:
"identifier_scheme": "ORCID", # Optional: identifies the author using ORCID # Error: TypeError: issubclass() arg 1 must be a class
If I comment out the "identifier_scheme" line, I can create a dataset. It's just missing the "Identifier Type":
Here's my script:
import os
from pyDataverse import Dataverse
api_token = os.getenv("API_TOKEN")
if not api_token:
raise SystemExit(
"Error: API_TOKEN is required.\n"
"Set it before running the script:\n"
' export API_TOKEN="your-dataverse-api-token"'
)
# First, connect to your Dataverse installation
dv = Dataverse(
base_url=os.getenv("DATAVERSE_URL", "https://demo.dataverse.org"),
api_token=api_token,
)
# Create a new dataset with basic information
dataset = dv.create_dataset(
title="My Research Dataset",
description="A comprehensive dataset containing experimental results from our study on machine learning algorithms",
authors=[
{
"name": "Jane Smith",
"affiliation": "University of Science",
# "identifier_scheme": "ORCID", # Optional: identifies the author using ORCID # Error: TypeError: issubclass() arg 1 must be a class
"identifier": "0000-0000-0000-0000" # Optional: the actual ORCID number
}
],
contacts=[
{
"name": "Jane Smith",
"email": "jane.smith@university.edu",
"affiliation": "University of Science" # Optional: where they work
}
],
subjects=["Computer and Information Science", "Engineering"], # Categories for the dataset
collection=":root"
)
# The dataset is now ready to use with all metadata blocks configured
# You can access the citation metadata block like this:
print(dataset.metadata_blocks["citation"].title)
# Output: 'My Research Dataset'
Here's the stacktrace when I uncomment the problematic line:
(venv) pdurbin@beamish create_dataset % python create_dataset.py
ℹ NativeApi: Connected to http://localhost:8080
ℹ Fetching metadata blocks...
ℹ Dataset factory initialized
Traceback (most recent call last):
File "/Users/pdurbin/github/gdcc/dataverse-recipes/python/create_dataset/create_dataset.py", line 20, in <module>
dataset = dv.create_dataset(
title="My Research Dataset",
...<17 lines>...
collection=":root"
)
File "/Users/pdurbin/github/gdcc/dataverse-recipes/python/create_dataset/venv/lib/python3.13/site-packages/pyDataverse/dataverse/dataverse.py", line 597, in create_dataset
dataset.upload_to_collection(collection)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^
File "/Users/pdurbin/github/gdcc/dataverse-recipes/python/create_dataset/venv/lib/python3.13/site-packages/pyDataverse/dataverse/dataset.py", line 732, in upload_to_collection
metadata=self.to_dataverse_create_dict(),
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
File "/Users/pdurbin/github/gdcc/dataverse-recipes/python/create_dataset/venv/lib/python3.13/site-packages/pyDataverse/dataverse/dataset.py", line 758, in to_dataverse_create_dict
metadata_blocks[name] = block.to_metadata_block()
~~~~~~~~~~~~~~~~~~~~~~~^^
File "/Users/pdurbin/github/gdcc/dataverse-recipes/python/create_dataset/venv/lib/python3.13/site-packages/pyDataverse/dataverse/connect/metadata.py", line 165, in to_metadata_block
processed_value = self._process_field_value(value, field_info)
File "/Users/pdurbin/github/gdcc/dataverse-recipes/python/create_dataset/venv/lib/python3.13/site-packages/pyDataverse/dataverse/connect/metadata.py", line 297, in _process_field_value
return [field.to_metadata_fields() for field in value]
~~~~~~~~~~~~~~~~~~~~~~~~^^
File "/Users/pdurbin/github/gdcc/dataverse-recipes/python/create_dataset/venv/lib/python3.13/site-packages/pyDataverse/dataverse/connect/metadata.py", line 523, in to_metadata_fields
processed_value = self._process_field_value(value, field_info)
File "/Users/pdurbin/github/gdcc/dataverse-recipes/python/create_dataset/venv/lib/python3.13/site-packages/pyDataverse/dataverse/connect/metadata.py", line 295, in _process_field_value
if issubclass(field_info.dtype, CompoundField):
~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: issubclass() arg 1 must be a class
(venv) pdurbin@beamish create_dataset %
The field "Identifier Type" is a controlled vocabulary, if that matters. Here's the dropdown:

As discussed in today's pyDataverse meeting, @liujinjie111 and I are both seeing a "TypeError: issubclass() arg 1 must be a class" when trying to follow the "create dataset" docs at https://gdcc.github.io/pyDataverse/high-level/dataverse/
I'm on this commit: 7f56e21
I've narrowed it down to this line, where I've added a comment locally:
"identifier_scheme": "ORCID", # Optional: identifies the author using ORCID # Error: TypeError: issubclass() arg 1 must be a classIf I comment out the "identifier_scheme" line, I can create a dataset. It's just missing the "Identifier Type":
Here's my script:
Here's the stacktrace when I uncomment the problematic line:
The field "Identifier Type" is a controlled vocabulary, if that matters. Here's the dropdown: