Skip to content

Commit

Permalink
Merge branch 'release/34.x'
Browse files Browse the repository at this point in the history
* release/34.x:
  #5149 - Page hangs when listing LLM models is not possible
  #5147 - Relations should be visible in the annotation sidebar when render mode is never
  #5145 - Managers and curators should be able to re-open their documents
  #5142 - DanglingRelationsCheck hammers database and runs very slow
  #5141 - Interactive recommenders should not be listed in the bulk-processing
  • Loading branch information
reckart committed Nov 6, 2024
2 parents 7fd1374 + ded84b7 commit 65bd2a7
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -260,12 +260,18 @@ public List<VObject> render(RenderRequest aRequest, List<AnnotationFeature> aFea
labelFeatures);
case WHEN_SELECTED:
if (aRequest.getState() == null || isSelected(aRequest, aFS, sourceFs, targetFs)) {
// State == null is when we render for the annotation sidebar...
return renderRelationAsArcs(aRequest, aVDocument, aFS, typeAdapter, sourceFs,
targetFs, labelFeatures);
}
return renderRelationOnLabel(aVDocument, typeAdapter, sourceFs, targetFs,
labelFeatures);
case NEVER:
if (aRequest.getState() == null) {
// State == null is when we render for the annotation sidebar...
return renderRelationAsArcs(aRequest, aVDocument, aFS, typeAdapter, sourceFs,
targetFs, labelFeatures);
}
return renderRelationOnLabel(aVDocument, typeAdapter, sourceFs, targetFs,
labelFeatures);
default:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,12 @@
import static de.tudarmstadt.ukp.inception.support.WebAnnoConst.FEAT_REL_TARGET;
import static de.tudarmstadt.ukp.inception.support.logging.LogLevel.INFO;

import java.util.HashMap;
import java.util.List;

import org.apache.uima.cas.CAS;
import org.apache.uima.cas.Feature;
import org.apache.uima.cas.Type;
import org.apache.uima.cas.text.AnnotationFS;

import de.tudarmstadt.ukp.clarin.webanno.model.SourceDocument;
Expand All @@ -51,7 +53,9 @@ public DanglingRelationsCheck(AnnotationSchemaService aAnnotationService)
public boolean check(SourceDocument aDocument, String aDataOwner, CAS aCas,
List<LogMessage> aMessages)
{
boolean ok = true;
var ok = true;

var adapterCache = new HashMap<Type, RelationAdapter>();

for (var fs : aCas.getAnnotationIndex()) {
var t = fs.getType();
Expand All @@ -64,8 +68,9 @@ public boolean check(SourceDocument aDocument, String aDataOwner, CAS aCas,
continue;
}

var relationAdapter = (RelationAdapter) annotationService
.findAdapter(aDocument.getProject(), fs);
var relationAdapter = adapterCache.computeIfAbsent(t,
_t -> (RelationAdapter) annotationService.findAdapter(aDocument.getProject(),
fs));

Feature relationSourceAttachFeature = null;
Feature relationTargetAttachFeature = null;
Expand All @@ -88,7 +93,7 @@ public boolean check(SourceDocument aDocument, String aDataOwner, CAS aCas,
target = (AnnotationFS) target.getFeatureValue(relationTargetAttachFeature);
}

// Does it have null endpoints?
// Does it have null end-points?
if (source == null || target == null) {
var message = new StringBuilder();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import java.net.http.HttpRequest;
import java.net.http.HttpRequest.BodyPublishers;
import java.net.http.HttpResponse;
import java.time.Duration;
import java.util.Comparator;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -141,6 +142,7 @@ public List<ChatGptModel> listModels(String aUrl, ListModelsRequest aRequest) th
.uri(URI.create(appendIfMissing(aUrl, "/") + "models")) //
.header(HttpHeaders.CONTENT_TYPE, "application/json").GET() //
.header("Authorization", "Bearer " + aRequest.getApiKey()) //
.timeout(Duration.ofSeconds(10)) //
.build();

var response = sendRequest(request);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.time.Duration;
import java.util.LinkedHashMap;
import java.util.Map;

Expand Down Expand Up @@ -82,6 +83,7 @@ public HfModelCard[] queryCatalog(Map<String, String> aQueryParameters) throws I

HttpRequest request = HttpRequest.newBuilder() //
.uri(URI.create(uriBuilder.toString())) //
.timeout(Duration.ofSeconds(10)) //
.build();

HttpResponse<String> response = sendRequest(request);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import java.net.http.HttpRequest.BodyPublishers;
import java.net.http.HttpResponse;
import java.nio.charset.StandardCharsets;
import java.time.Duration;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
Expand Down Expand Up @@ -142,6 +143,7 @@ public List<OllamaModel> listModels(String aUrl) throws IOException
var request = HttpRequest.newBuilder() //
.uri(URI.create(appendIfMissing(aUrl, "/") + "api/tags")) //
.header(HttpHeaders.CONTENT_TYPE, "application/json").GET() //
.timeout(Duration.ofSeconds(10)) //
.build();

var response = sendRequest(request);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,10 @@ private List<Recommender> listRecommenders()
var factory = maybeFactory.get();
var engine = factory.build(recommender);

if (factory.isInteractive(recommender)) {
continue;
}

// If a recommender requires training, it would yield no results if the user has not yet
// annotated any documents. So in this case, we do currently not offer it for
// processing.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import static de.tudarmstadt.ukp.clarin.webanno.model.AnnotationDocumentState.IN_PROGRESS;
import static de.tudarmstadt.ukp.clarin.webanno.model.AnnotationDocumentStateChangeFlag.EXPLICIT_ANNOTATOR_USER_ACTION;
import static de.tudarmstadt.ukp.clarin.webanno.model.PermissionLevel.CURATOR;
import static de.tudarmstadt.ukp.clarin.webanno.model.PermissionLevel.MANAGER;
import static de.tudarmstadt.ukp.clarin.webanno.model.SourceDocumentState.CURATION_FINISHED;
import static de.tudarmstadt.ukp.clarin.webanno.model.SourceDocumentState.CURATION_IN_PROGRESS;
import static de.tudarmstadt.ukp.inception.support.WebAnnoConst.CURATION_USER;
Expand Down Expand Up @@ -280,8 +281,10 @@ private void actionToggleDocumentState(AjaxRequestTarget aTarget)
return;
}

var sessionOwner = userRepository.getCurrentUser();
var annDoc = documentService.getAnnotationDocument(document, state.getUser());
if (annDoc.getAnnotatorState() != annDoc.getState()) {
if (annDoc.getAnnotatorState() != annDoc.getState()
&& !projectService.hasRole(sessionOwner, state.getProject(), CURATOR, MANAGER)) {
error("Annotation state has been overridden by a project manager or curator. "
+ "You cannot change it.");
aTarget.addChildren(getPage(), IFeedback.class);
Expand Down

0 comments on commit 65bd2a7

Please sign in to comment.