Skip to content

test script fails on test server #171

@cmeesters

Description

@cmeesters

Hi,

trying the script

import rdflib
from rdflib import Graph
from nanopub import Nanopub, NanopubConf, load_profile

# 1. Create the config
np_conf = NanopubConf(
    use_test_server=True,
    profile=load_profile(), # Loads the user profile that was created with `np setup`
    add_prov_generated_time=True,
    attribute_publication_to_profile=True,
)

# 2. Construct a desired assertion (a graph of RDF triples) using rdflib
my_assertion = Graph()
my_assertion.add((
    rdflib.URIRef('www.example.org/timbernerslee'),
    rdflib.RDF.type,
    rdflib.FOAF.Person
))

# 2. Make a Nanopub object with this assertion
np = Nanopub(
    conf=np_conf,
    assertion=my_assertion
)

# 3. Publish the Nanopub object
np.publish()
print(np)

fails with

Traceback (most recent call last):
  File "/home/meesters/Documents/Teaching/nanopubs_python/testnp.py", line 28, in <module>
    np.publish()
  File "/home/meesters/miniforge3/envs/nanopub/lib/python3.12/site-packages/nanopub/nanopub.py", line 201, in publish
    publish_graph(self.rdf, use_server=self._conf.use_server)
  File "/home/meesters/miniforge3/envs/nanopub/lib/python3.12/site-packages/nanopub/sign_utils.py", line 118, in publish_graph
    r.raise_for_status()
  File "/home/meesters/miniforge3/envs/nanopub/lib/python3.12/site-packages/requests/models.py", line 1024, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 400 Client Error:  for url: https://np.test.knowledgepixels.com/

Note, that the example requires another import rdflib, which is missing in the README file, too.

Perhaps an issue with the testserver? @tkuhn (However, I am able to ping it and the URL displays just fine ...)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions