Skip to content

Commit

Permalink
small code changes
Browse files Browse the repository at this point in the history
  • Loading branch information
carlosuc3m committed Oct 30, 2023
1 parent 1ae7019 commit a5ba5ce
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,9 @@ public class DownloadModel {
* @param descriptor
* information about the model from the rdf.yaml
*/
private DownloadModel(ModelDescriptor descriptor, String modelsDir, Thread parentThread) {
private DownloadModel(ModelDescriptor descriptor, String modelsDir) {
this.descriptor = descriptor;
this.parentThread = parentThread;
this.parentThread = Thread.currentThread();
String fname = addTimeStampToFileName(descriptor.getName(), true);
this.modelsDir = modelsDir + File.separator + getValidFileName(fname);
this.consumer = (String b) -> {
Expand Down Expand Up @@ -202,7 +202,7 @@ public String getModelFolder() {
* @return object that can be handles the download of all the files needed for a model
*/
public static DownloadModel build(ModelDescriptor descriptor, String modelsDir) {
return new DownloadModel(descriptor, modelsDir, Thread.currentThread());
return new DownloadModel(descriptor, modelsDir);
}

/**
Expand All @@ -212,7 +212,7 @@ public static DownloadModel build(ModelDescriptor descriptor, String modelsDir)
* @return object that can be handles the download of all the files needed for a model
*/
public static DownloadModel build(ModelDescriptor descriptor) {
return new DownloadModel(descriptor, new File("models").getAbsolutePath(), Thread.currentThread());
return new DownloadModel(descriptor, new File("models").getAbsolutePath());
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -484,10 +484,9 @@ public static TwoParameterConsumer<String, Double> createConsumerProgress() {
* too
* @param consumer
* consumer that provides the info about the download
* @throws InterruptedException if the thread is stopped by other thread while it is sleeping
*/
public static void printProgress(Thread downloadThread,
DownloadTracker.TwoParameterConsumer<String, Double> consumer) throws InterruptedException {
DownloadTracker.TwoParameterConsumer<String, Double> consumer) {
int n = 30;
String ogProgressStr = "";
String ogRemainingStr = "";
Expand All @@ -500,7 +499,7 @@ public static void printProgress(Thread downloadThread,
while (Thread.currentThread().isAlive() && (downloadThread.isAlive() || keep)) {
boolean end = consumer.get().keySet().contains(TOTAL_PROGRESS_KEY)
&& consumer.get().get(TOTAL_PROGRESS_KEY) == 1.0;
Thread.sleep(keep == true || end ? 10 : 3000);
try {Thread.sleep(keep == true || end ? 10 : 3000);} catch (InterruptedException ex) {}
keep = false;
String select = null;
for (String key : consumer.get().keySet()) {
Expand Down

0 comments on commit a5ba5ce

Please sign in to comment.