Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor out SPIN #184

Open
blcham opened this issue Jul 29, 2023 · 5 comments · May be fixed by #251
Open

Refactor out SPIN #184

blcham opened this issue Jul 29, 2023 · 5 comments · May be fixed by #251
Assignees
Labels

Comments

@blcham
Copy link
Contributor

blcham commented Jul 29, 2023

STEPS:

  • check first if it is not possible to upgrade to SHACL while having SPIN as well
  • if not create tests for all usecases where SPIN functionalities are used (e.g. RDF function definition)
  • try to get rid of the implementation
  • upgrade Jena and JOPA to newest version -- should also upgrade JSONLD library to https://github.com/filip26/titanium-json-ld
@blcham
Copy link
Contributor Author

blcham commented Jul 29, 2023

Related issues #43 #44

@blcham
Copy link
Contributor Author

blcham commented Aug 2, 2024

Additional notes:

  • SHACL is the replacement for SPIN that we should use
  • The relevant library that needs to be upgraded is in s-pipes core:
              <groupId>org.topbraid</groupId>
              <artifactId>shacl</artifactId>
              <version>1.0.1</version>
    
    I believe this is the last version of SHACL library that still contains the SPIN API. Here is also migration guide from SPIN to SHACL -- https://spinrdf.org/spin-shacl.html.

@blcham
Copy link
Contributor Author

blcham commented Aug 2, 2024

Next steps:

  • Choose SHACL library to replace SPIN (jena-shacl vs. topbraid-shacl) -- here is comparison
    • we should use jena-shacl if possible, as it is not vendor-locked. For now, I do not see any specific topbraid-shacl feature that we need.
  • modify/extend Spin integration test to SHACLIntegrationTest to test needed features. Follow the migration guide. We need to:
    • migrate all SPARQL functions written in Java from SPIN to SHACL (e.g. AddDays.java) and make test to prove they work in a SPARQL query
    • be able to define a specific function in RDF and then call it in SPARQL query
    • migrate doc/examples to use SHACL instead of SPIN (note we can but not have to support loading it through SPIN namespace, i.e. sp:Select, sp:text etc.)

@blcham
Copy link
Contributor Author

blcham commented Aug 2, 2024

@palagdan let's start implementation without upgrading SHACL library:

migrate all SPARQL functions written in Java from SPIN to SHACL (e.g. AddDays.java) and make test to prove they work in a SPARQL query

STEPS:

I created initial PR -- #251

@blcham blcham linked a pull request Aug 2, 2024 that will close this issue
@blcham blcham changed the title Consider refactoring out SPIN Refactor out SPIN Aug 2, 2024
@palagdan
Copy link
Collaborator

palagdan commented Aug 6, 2024

@blcham
I tested the AddDays function you provided:

@Test
    public void executeSPINQueryWithCustomJavaFunction() {
        PipelineFactory pipelineFactory = new PipelineFactory();

        String queryString = """
                PREFIX kbss-timef: <http://onto.fel.cvut.cz/ontologies/lib/function/time/>
                PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
                SELECT ?nextDay 
                WHERE {
                  BIND(kbss-timef:add-days("2022-01-01"^^xsd:date, 1) AS ?nextDay)
                }
                """;
        Model model = ModelFactory.createDefaultModel();

        Query query = QueryFactory.create(queryString);


        QueryExecution qexec = QueryExecutionFactory.create(query, model);
        ResultSet results = qexec.execSelect();

        if (results.hasNext()) {
            QuerySolution soln = results.nextSolution();
            assertEquals(soln.getLiteral("nextDay").getString(), "2022-01-02");
        }
    }

The test works fine. PipelineFactory registers all S-PIPES modules and functions.

However, I’m unsure how to reimplement functions like AddDays using SHACL because there is no available documentation on how to use the SHACL API.

Additionally, why should AddDays extend the SPIN AbstractFunction class? Since SPIN is designed for constraints and AddDays is a function that produces a Date output.

@blcham blcham added the blocked label Aug 8, 2024
blcham added a commit that referenced this issue Aug 14, 2024
blcham added a commit that referenced this issue Aug 15, 2024
blcham added a commit that referenced this issue Aug 15, 2024
blcham added a commit that referenced this issue Aug 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Development

Successfully merging a pull request may close this issue.

2 participants