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

Fixes scripts not updating on change in development mode #245

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public Module loadModule(final String moduleId,

// TODO check moduleTypeUri

return PipelineFactory.loadPipeline(scriptsRepository.getResource(resourceUri, resourceContextUri));
return PipelineFactory.loadModule(scriptsRepository.getResource(resourceUri, resourceContextUri));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure that this is ok, i will check

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

loadPipeline() loads the script from the saved pipeline, not from the file we've changed, if I remember correctly. So, it will use the old version of the script.

}

public Module loadFunction(String functionId) {
Expand Down Expand Up @@ -116,6 +116,10 @@ public Set<String> getGlobalScripts() {
return globalScripts;
}

public boolean doesRegistryContainsEntity(String entityId) {
return moduleRegistry.doesContextContainsEntity(entityId);
}


// id -> contexts
// function id-s
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,10 @@ public Set<String> getContexts(String entityId) {
return getResourceUri(entityId, contexts.iterator().next());
}

public boolean doesContextContainsEntity(String entityId) {
return fullName2ContextsMap.containsKey(entityId);
}



private Set<String> getLocalName2Contexts(String localEntityId) {
Expand All @@ -145,6 +149,7 @@ private boolean isLocalNameEntityId(String entityId) {
return !(isPrefixedEntityId(entityId) || isFullNameEntityId(entityId));
}


private boolean isFullNameEntityId(String entityId) {
return entityId.contains("#") || entityId.contains("/");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,6 @@ public interface ResourceRegistry {


@NotNull String getResourceUri(@NotNull String entityId) throws ResourceNotFoundException, ResourceNotUniqueException;

@NotNull boolean doesContextContainsEntity(@NotNull String entityId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,7 @@
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.*;
import java.net.URL;
import java.util.*;
import java.util.stream.Collectors;
Expand Down Expand Up @@ -221,7 +219,13 @@ private Model runModule(final Model inputDataModel, final MultiValueMap<String,

ExecutionEngine engine = createExecutionEngine(configModel);
ContextLoaderHelper.updateContextsIfNecessary(scriptManager);
Module module = PipelineFactory.loadModule(configModel.createResource(id));
Module module = null;
if (scriptManager.doesRegistryContainsEntity(id)) {
module = scriptManager.loadModule(id, null, null);
}
else {
module = PipelineFactory.loadModule(configModel.createResource(id));
}
if (module == null) {
throw new SPipesServiceException("Cannot load module with id=" + id);
}
Expand Down Expand Up @@ -358,7 +362,11 @@ Model loadModelFromUrl(@NotNull String modelUrl) {
private void extendBindingFromURL(VariablesBinding inputVariablesBinding, URL inputBindingURL) {
try {
final VariablesBinding vb2 = new VariablesBinding();
vb2.load(inputBindingURL.openStream(), FileUtils.langTurtle);
String path = inputBindingURL.getPath();
File file = new File(path);
InputStream is = new FileInputStream(file);
vb2.load(is, FileUtils.langTurtle);
//vb2.load(inputBindingURL.openStream(), FileUtils.langTurtle);
VariablesBinding vb3 = inputVariablesBinding.extendConsistently(vb2);
if (vb3.isEmpty()) {
log.debug("- no conflict between bindings loaded from '{}' and those provided in query string.",
Expand Down
Loading