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 3 commits into
base: main
Choose a base branch
from

Conversation

MSattrtand
Copy link
Collaborator

Resolves #227

@MSattrtand MSattrtand changed the base branch from main to 231-improve-query-parse-error-logging July 21, 2024 21:00
@MSattrtand MSattrtand changed the base branch from 231-improve-query-parse-error-logging to main July 21, 2024 21:01
@MSattrtand MSattrtand force-pushed the 227-fixes-scripts-not-updating-on-change branch from de19731 to 5c827bd Compare July 21, 2024 21:47
@blcham blcham force-pushed the 227-fixes-scripts-not-updating-on-change branch from 79cc0dd to bb83ef1 Compare January 8, 2025 12:50
Copy link
Contributor

@blcham blcham left a comment

Choose a reason for hiding this comment

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

Please comment on how it solves the issue

@@ -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.

Copy link
Contributor

Choose a reason for hiding this comment

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

Here some detail is needed to understand if we need to refactor or it is reasonable change.

@blcham blcham force-pushed the 227-fixes-scripts-not-updating-on-change branch from bb83ef1 to 9105376 Compare February 3, 2025 10:52
@blcham blcham self-requested a review February 3, 2025 10:53
Copy link
Contributor

@blcham blcham left a comment

Choose a reason for hiding this comment

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

See my comments.

@@ -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();
Copy link
Contributor

Choose a reason for hiding this comment

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

I do not understand why you are doing this ... and believe there will be inputstream that we will never close

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

If we are using old method, so vb2.load(inputBindingURL.openStream(), FileUtils.langTurtle);, we'll get exception

java.net.ConnectException: Connection refused: getsockopt

E. g. if we want to rerun construct-greeting, we'll get:
image
We do not have id or is-greeted-by-message, unlike here with my changes:
image

So, I'm loading the pipeline another way since it is saved on a disc.

@@ -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)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why using once scriptManager and then PipelineFactory?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'm trying to load it from the scriptManager if the required module exists there. If it does not, e.g. we have deleted it from the file. In this case, I'm trying to load it from the saved pipeline (so it is the last saved instance before deletion), so we would have at least some working module. I'm not sure if it is the best solution; maybe it would be better to let the code throw an exception in
if (module == null) { throw new SPipesServiceException("Cannot load module with id=" + id); }
In case we are trying to load a non-existing module

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Also, deleting an attempt to load with PiplelineFactory will cause test failures, so the tests should be changed in this case

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Scripts in ApplyConstruct module not automatically updated on change of query
2 participants