Skip to content

Commit

Permalink
remove skema-py (#6565)
Browse files Browse the repository at this point in the history
  • Loading branch information
YohannParis authored Feb 11, 2025
1 parent d967ff8 commit 2e96de2
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 88 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,21 @@
import java.util.List;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.text.StringEscapeUtils;
import org.apache.http.HttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.springframework.http.ResponseEntity;
import org.springframework.security.access.annotation.Secured;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.server.ResponseStatusException;
import software.uncharted.terarium.hmiserver.models.StoredModel;
import software.uncharted.terarium.hmiserver.models.code.CodeRequest;
import software.uncharted.terarium.hmiserver.models.code.GithubFile;
import software.uncharted.terarium.hmiserver.models.code.GithubRepo;
import software.uncharted.terarium.hmiserver.proxies.github.GithubProxy;
import software.uncharted.terarium.hmiserver.proxies.jsdelivr.JsDelivrProxy;
import software.uncharted.terarium.hmiserver.proxies.skema.SkemaProxy;
import software.uncharted.terarium.hmiserver.proxies.skema.SkemaRustProxy;
import software.uncharted.terarium.hmiserver.security.Roles;

@Slf4j
Expand All @@ -39,67 +33,6 @@ public class CodeController {

private final JsDelivrProxy jsdelivrProxy;

private final SkemaProxy skemaProxy;

private final SkemaRustProxy skemaRustProxy;

/**
* Stores a model from a code snippet
*
* @param code the python code snippet
* @return a {@link StoredModel} instance containing the model id, inputs, and outputs of the model derived from the
* code input
*/
@PostMapping
@Secured(Roles.USER)
@ApiResponses(
value = {
@ApiResponse(responseCode = "200", description = "Code transformed successfully"),
@ApiResponse(responseCode = "204", description = "No content")
}
)
public ResponseEntity<StoredModel> transformCode(final String code) {
// Convert from highlighted code a function network
final String skemaResponseStr;
try {
skemaResponseStr = skemaProxy.getFunctionNetwork(new CodeRequest(code)).getBody();
} catch (final FeignException e) {
final String error = "Error creating function network from code";
final int status = e.status() >= 400 ? e.status() : 500;
log.error(error, e);
throw new ResponseStatusException(org.springframework.http.HttpStatus.valueOf(status), error);
}

if (skemaResponseStr == null || skemaResponseStr.isEmpty()) {
return ResponseEntity.noContent().build();
}

// The model is returned from Skema as escaped, quoted json. Eg:
// "{\"hello\": \"world\" .... }"
// We must remove the leading and trailing quotes, and un-escape the json in
// order to pass it on to the
// service that will store the model as it expects application/json and not a
// string
final String unescapedSkemaResponseStr = StringEscapeUtils.unescapeJson(
skemaResponseStr.substring(1, skemaResponseStr.length() - 1)
);

// Store the model
try {
final String modelId = skemaRustProxy.addModel(unescapedSkemaResponseStr).getBody();

final String odiResponseStr = skemaRustProxy.getModelNamedOpis(modelId).getBody();
final String odoResponseStr = skemaRustProxy.getModelNamedOpos(modelId).getBody();

return ResponseEntity.ok(new StoredModel().setId(modelId).setInputs(odiResponseStr).setOutputs(odoResponseStr));
} catch (final FeignException e) {
final String error = "transforming code to model failed";
final int status = e.status() >= 400 ? e.status() : 500;
log.error(error, e);
throw new ResponseStatusException(org.springframework.http.HttpStatus.valueOf(status), error);
}
}

@GetMapping("/repo-content")
@Secured(Roles.USER)
@ApiResponses(
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ terarium.file-storage-s3-bucket-name=askem-staging-data-service
########################################################################################################################
# Microservice configuration
########################################################################################################################
skema-py.url=https://skema-py.staging.terarium.ai
skema-rs.url=https://skema-rs.staging.terarium.ai
skema-unified.url=https://skema-unified.staging.terarium.ai
ciemss-service.url=https://pyciemss.staging.terarium.ai
Expand Down
1 change: 0 additions & 1 deletion packages/server/src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,6 @@ terarium.static-index-path=askem-static-index
github.url=https://api.github.com
jsdelivr.url=https://cdn.jsdelivr.net
mira-api.url=http://mira-epi-dkg-lb-dc1e19b273dedaa2.elb.us-east-1.amazonaws.com
skema-py.url=https://skema-py.staging.terarium.ai
skema-rs.url=https://skema-rs.staging.terarium.ai
skema-unified.url=https://skema-unified.staging.terarium.ai
ciemss-service.url=https://pyciemss.staging.terarium.ai
Expand Down

0 comments on commit 2e96de2

Please sign in to comment.