Skip to content

Commit

Permalink
Check if pypi coordinate exists through the inspection of the package…
Browse files Browse the repository at this point in the history
… endpoint
  • Loading branch information
gdrosos committed Feb 20, 2023
1 parent 9c0ef30 commit 508c171
Showing 1 changed file with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -126,10 +126,19 @@ public boolean ingestPypiArtifactIfNecessary(String packageName, String version)
+ " could not be found. Make sure the PyPI coordinate is correct");
}
if (!hasArtifactBeenIngested(packageName, version)) {
JSONObject json = new JSONObject(result);

//Check if the specific package version exists on PyPI
JsonObject releases = JsonParser.parseString(result).getAsJsonObject()
.get("releases").getAsJsonObject();
if (!releases.has(version)) {
throw new IllegalArgumentException("PyPI package version " + packageName + ":" + version
+ " could not be found. Make sure the PyPI coordinate is correct");
}

var projectInfo = new JSONObject(result);
var jsonRecord = new JSONObject();
jsonRecord.put("title", packageName + " " + version);
jsonRecord.put("project", json);
jsonRecord.put("project", projectInfo);
jsonRecord.put("ingested", true);
KnowledgeBaseConnector.kbDao.insertIngestedArtifact(toPypiKey(packageName, version), "0.1.1-SNAPSHOT");
if (KnowledgeBaseConnector.kafkaProducer != null && KnowledgeBaseConnector.ingestTopic != null) {
Expand Down

0 comments on commit 508c171

Please sign in to comment.