Skip to content

Commit

Permalink
Patch 20240708a2
Browse files Browse the repository at this point in the history
Add error handle for pip
Support test for text generation models
  • Loading branch information
EndermanPC committed Jul 8, 2024
1 parent 33463cb commit fd9f223
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 23 deletions.
24 changes: 17 additions & 7 deletions Create.cs
Original file line number Diff line number Diff line change
Expand Up @@ -137,14 +137,22 @@ private async Task InstallPackageDependencies(string language)
}
await UpdateProgressBarAsync(35);

ProcessStartInfo start = new ProcessStartInfo();
start.FileName = $"projects\\{textBox1.Text}\\python\\Scripts\\python.exe";
start.Arguments = "-m pip install python-dotenv " + string.Join(" ", packageRequirements);
start.UseShellExecute = true;
start.RedirectStandardOutput = false;
try
{
ProcessStartInfo start = new ProcessStartInfo();
start.FileName = $"projects\\{textBox1.Text}\\python\\Scripts\\python.exe";
start.Arguments = "-m pip install python-dotenv " + string.Join(" ", packageRequirements);
start.UseShellExecute = true;
start.RedirectStandardOutput = false;

await UpdateProgressBarAsync(40);
Process process = Process.Start(start);
await UpdateProgressBarAsync(40);
Process process = Process.Start(start);
}
catch (Exception ex)
{
MessageBox.Show($"Error installing python packages: {ex.Message}", "Exception Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
Environment.Exit(1);
}

await UpdateProgressBarAsync(50);
}
Expand All @@ -157,6 +165,7 @@ private async Task DownloadFilesForTGRNN(string projectPath)
{
var baseUri = "https://raw.githubusercontent.com/Lithicsoft/Lithicsoft-Trainer-Studio/main/rnn_text_generation/";
await client.DownloadFileTaskAsync(new Uri(baseUri + "trainer.py"), $"projects\\{projectPath}\\trainer.py");
await client.DownloadFileTaskAsync(new Uri(baseUri + "tester.py"), $"projects\\{projectPath}\\tester.py");
await client.DownloadFileTaskAsync(new Uri(baseUri + ".env"), $"projects\\{projectPath}\\.env");
await UpdateProgressBarAsync(20);
}
Expand All @@ -176,6 +185,7 @@ private async Task DownloadFilesForTGLSTM(string projectPath)
{
var baseUri = "https://raw.githubusercontent.com/Lithicsoft/Lithicsoft-Trainer-Studio/main/lstm_text_generation/";
await client.DownloadFileTaskAsync(new Uri(baseUri + "trainer.py"), $"projects\\{projectPath}\\trainer.py");
await client.DownloadFileTaskAsync(new Uri(baseUri + "tester.py"), $"projects\\{projectPath}\\tester.py");
await client.DownloadFileTaskAsync(new Uri(baseUri + ".env"), $"projects\\{projectPath}\\.env");
await UpdateProgressBarAsync(20);
}
Expand Down
25 changes: 25 additions & 0 deletions Python.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 15 additions & 14 deletions Python.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,13 @@ public Python(string name, string language, string type)

textBox2.Text = $"projects\\{projectName}";

if (File.Exists($"projects\\{projectName}\\tester.py"))
{
label7.Text = "Test model";
button6.Enabled = true;
textBox4.Enabled = true;
}

trainParameters = DotEnv.Load($"projects\\{projectName}\\.env");
listView1.View = View.Details;
listView1.Columns.Add("Variable", -2, HorizontalAlignment.Left);
Expand Down Expand Up @@ -162,25 +169,19 @@ await Task.Run(() =>
button3.Enabled = true;
}

private void InitModel()
{
try
{
// working
}
catch (Exception ex)
{
MessageBox.Show($"Error loading model: {ex.Message}", "Exception Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}

private void button6_Click(object sender, EventArgs e)
{
try
{
InitModel();
File.WriteAllText($"projects\\{projectName}\\prompt.txt", textBox4.Text);

ProcessStartInfo start = new ProcessStartInfo();
start.FileName = $"projects\\{projectName}\\python\\Scripts\\python.exe";
start.Arguments = $"projects{projectName}\\tester.py";
start.UseShellExecute = true;
start.RedirectStandardOutput = false;

//working
Process process = Process.Start(start);
}
catch (Exception ex)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
[assembly: System.Reflection.AssemblyCompanyAttribute("Lithicsoft Trainer Studio")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+8562805c7a99d4a44f355d67b61eabb6a223c099")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+33463cb489d7577e18a6f88c942f01223de5e572")]
[assembly: System.Reflection.AssemblyProductAttribute("Lithicsoft Trainer Studio")]
[assembly: System.Reflection.AssemblyTitleAttribute("Lithicsoft Trainer Studio")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
775123c45f918709ae8514842fbdca02b15f0e0657ca360315273dd4fa094d29
f9b746c125238d75aa88c66f255bf9a67a09d92d3fb9216b7e3e492a2c89a81d

0 comments on commit fd9f223

Please sign in to comment.