Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Alphapeptdeep Integration #3123

Open
wants to merge 19 commits into
base: master
Choose a base branch
from

Conversation

xgwang-uw
Copy link
Contributor

  • Rename existing PythonInstaller to PythonInstallerLegacyDlg
  • Add new PythonInstaller implementation to support Python virtual environment
  • Add functional tests for new PythonInstaller implementation

@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="OneOf" version="3.0.271" targetFramework="net472" />
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This works on my development machine, but the build on TeamCity seems to be failing because it does not see this dll.

So far we have been adding all of the dll's that we need to:
pwiz_tools/Shared/lib

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For modern Nuget we use PackageReference, like this for Ardia in the Skyline.csproj file:

  <ItemGroup>
    <PackageReference Include="Microsoft.Web.WebView2">
      <Version>1.0.2420.47</Version>
    </PackageReference>
  </ItemGroup>

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good. Thanks for the suggestion here. I've updated OneOf to use PackageReference. It works locally. Let's see if the teamcity test can pass now

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Everything builds fine on TeamCity, but now it looks like "OneOf.dll" is not getting copied to where it needs to go.
The test "CheckForMissingResources" is failing to load "Skyline-daily.exe":

System.IO.FileNotFoundException: Could not load file or assembly 'OneOf, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.
File name: 'OneOf, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'

Does anyone know how to fix something like this?

@chambm
Copy link
Member

chambm commented Aug 20, 2024

Something went wrong with the merge here. It shouldn't show changes from other PRs. Maybe try fetching latest master and rebasing your branch on it. Do you need help doing that?.

@nickshulman
Copy link
Contributor

nickshulman commented Aug 20, 2024

Something went wrong with the merge here.

My guess is that pushing "Update branch" will fix everything.
This branch has changes from master but does not know that it is up to date with master.
If we push the "Update branch" button it will notice all the files that it wants to change are identical to what is already there and everything will be good.

@xgwang-uw xgwang-uw force-pushed the Skyline/work/20240816_pythoninstaller_with_virtual_env_support branch from 868fde7 to 416c9d2 Compare August 20, 2024 19:43
@xgwang-uw
Copy link
Contributor Author

Something went wrong with the merge here. It shouldn't show changes from other PRs. Maybe try fetching latest master and rebasing your branch on it. Do you need help doing that?.

Yeah. Thanks for asking. I did a rebase which treated the updated changes and anything in between as new commits. I rolled back those changes and added the updates as a new commit. That fixed this branch. I will do a merge from master later on.

@xgwang-uw xgwang-uw force-pushed the Skyline/work/20240816_pythoninstaller_with_virtual_env_support branch 3 times, most recently from 3db9cca to b007485 Compare August 21, 2024 22:40
@chambm
Copy link
Member

chambm commented Aug 22, 2024

On TeamCity the TestData test runs from an installed directory (installed with the WIX-based installer). Any non-vendor DLLs have to be added into Product-template.wxs manually. We didn't hit this on the Ardia PR because the Ardia tests are in TestConnected, which doesn't run under the admin-installed instance. Nick, we have both hit this snag many times over the years and it's funny how easily we forget it. :) I think I once proposed grepping for DLLs in the csproj files in the past but never got around to implementing it.

@xgwang-uw xgwang-uw force-pushed the Skyline/work/20240816_pythoninstaller_with_virtual_env_support branch from a4971e8 to 7812cb5 Compare August 26, 2024 19:58
@xgwang-uw xgwang-uw changed the title Skyline/work/20240816 pythoninstaller with virtual env support Alphapeptdeep Integration Sep 9, 2024
Copy link
Contributor

@nickshulman nickshulman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! This works great (usually).
I did run into a couple of problems.

private string PeptdeepExecutablePath => Path.Combine(PythonVirtualEnvironmentScriptsDir, PEPTDEEP_EXECUTABLE);
private string RootDir => Path.Combine(ToolDescriptionHelpers.GetToolsDirectory(), ALPHAPEPTDEEP);
private string SettingsFilePath => Path.Combine(RootDir, SETTINGS_FILE_NAME);
private string InputFileName => INPUT + UNDERSCORE +Document.DocumentHash +EXT_TSV;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Document.DocumentHash" might contain the character "/" which would cause problems here.

You could use "PathEx.ReplaceInvalidFilenameCharacters" to get rid of that.
It might make more sense to put all of the temporary files into a subfolder of the .blib file that is being created. That is, if the user is building "foo.blib" then all of the temporary files go into "foo.blib.temp".
We know that the user has write permissions on the folder where the .blib file is being created.
I am not sure whether we are guaranteed that the user will be able to write to the tools directory.

{
// TODO(xgwang): update this exception to an Alphapeptdeep specific one
throw new Exception(
@$"Modification {mod} is missing unimod ID, which is required by AlphapeptdeepLibraryBuilder");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ModifiedSequence.Modification does not override ToString(), so you should use {mod.Name} here instead of {mod}.

It would probably be better to keep track of all of the unsupported modifications that were found, and skip over those peptides, and build a library with as many peptides as possible, and at the end show the list of unsupported modifications which caused some peptides to be skipped.

Copy link
Contributor

@brendanx67 brendanx67 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here is a first review of the code with some requested changes.

/// </summary>
private static readonly Dictionary<int, string> AlphapeptdeepModificationName = new Dictionary<int, string>()
{
{4, @"Carbamidomethyl@C"},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In hindsight, these are going to need to be detected by mass and amino acid. It is possible to have these modifications without their being correctly identified by unimod ID.

/// The peptdeep cmd-flow command is how we can pass arguments that will override the settings.yaml file.
/// This is how the peptdeep CLI supports command line arguments.
/// </summary>
private Dictionary<string, string> CmdFlowCommandArguments =>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dictionaries are inherently unordered. This would be better expressed with an IList<Tuple<string, string>> Or IList<KeyValuePair<string, string>>. Or often I recommend just creating a struct or class with a name and well named members to make the code as self documenting as possible: IList.

}
}

private static string CreateDirIfNotExist(string dir)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is redundant. CreateDirectory() already works this way.

{
// TODO(xgwang): update this exception to an Alphapeptdeep specific one
throw new Exception(
@$"Modification {mod} is missing unimod ID, which is required by AlphapeptdeepLibraryBuilder");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Exception text that will be shown to the user needs to be localizable. So, it will need to be put in a RESX file, which means you can't use @ and you can't use this kind of inline value expansion.

{
// TODO(xgwang): update this exception to an Alphapeptdeep specific one
throw new Exception(
@$"Modification with unimod ID of {unimodId} is not yet supported by Alphapeptdeep. Please remove such modifications and try again.");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs to be in a RESX file.

@@ -286,7 +297,7 @@ private bool ValidateBuilder(bool validateInputFiles)
// TODO: Probably need to validate that all the libraries can be loaded into memory with progress UI
}

// TODO: Create CarafeLibraryBuilder class with everything necessary to build a library
// TODO: Create AlphapeptdeepLibraryBuilder class with everything necessary to build a library
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like the original text is still appropriate.

@@ -132,7 +132,7 @@
<value>1</value>
</data>
<metadata name="helpTip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>155, 17</value>
<value>148, 17</value>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again, unclear why the form should need to change at all for this PR.

@@ -30,6 +30,7 @@
<ResolveAssemblyWarnOrErrorOnTargetArchitectureMismatch>None</ResolveAssemblyWarnOrErrorOnTargetArchitectureMismatch>
<EnableSecurityDebugging>false</EnableSecurityDebugging>
<AutoGenerateBindingRedirects>false</AutoGenerateBindingRedirects>
<RuntimeIdentifier>win</RuntimeIdentifier>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this change necessary?


namespace pwiz.Skyline.ToolsUI
{
public partial class PythonInstallerDlg : FormEx
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should just use MessageDlg or MultiButtonMessageDlg instead of this custom form. All it does now is show a message and buttons. There are other good examples of this for installation.

}
namespace pwiz.Skyline.ToolsUI
{
partial class PythonInstallerLegacyDlg
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lots of whitespace changing in the files associated with PythonInstallerLegacyDlg. Turning off whitespace diffs the changes look much more like the simple rename expected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants