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

Import SATF Library Sequence #1592

Open
wants to merge 7 commits into
base: develop
Choose a base branch
from
Open

Import SATF Library Sequence #1592

wants to merge 7 commits into from

Conversation

goetzrrGit
Copy link
Contributor

@goetzrrGit goetzrrGit commented Jan 14, 2025

Closes #1591

Library Sequence Modal:

  • Introduced a new modal for importing a library sequence file.
  • Integrated the library modal with workspaces for seamless interaction.

Linting Bugfix:

  • Fixed an issue where the linter incorrectly reported errors for values within a valid range when multiple ranges were defined.
  • Fixed an issue where the linter incorrectly reported errors for command stems with no arguments.

Autocomplete Bugfix:

  • Improved autocomplete functionality to allow completion even with invalid variable types. The user will be notified of the invalid type within the editor and will need to manually correct it.

SATF/SASF Library

  • Fixed an issue where we were not generating the @model correctly.

TESTING

  • Download the attach file (banana_library.txt)
  • Rename it to banana_library.satf
  • Create a new workspace
  • In the middle panel underneath the 'create sequence' you should see a 'import library'
  • Click on 'import library' and select a parcel and library file ex. banana_library.satf
  • Verify the library gets imported and you see 3 sequences created

banana_library.txt

@goetzrrGit goetzrrGit added feature New feature or request sequencing Anything related to the sequencing domain labels Jan 14, 2025
@goetzrrGit goetzrrGit self-assigned this Jan 14, 2025
@goetzrrGit goetzrrGit requested a review from a team as a code owner January 14, 2025 21:49
@goetzrrGit goetzrrGit requested a review from AaronPlave January 14, 2025 21:49
@cohansen
Copy link
Contributor

Is this branch supposed to merge into #1574? It looks like a lot of the same changes.

@goetzrrGit
Copy link
Contributor Author

Is this branch supposed to merge into #1574? It looks like a lot of the same changes.

Yeah it is branched from 1574 and since that was merged in the first 4 fell off. It should now all be new code

@@ -86,6 +125,18 @@
>
New Sequence
</button>

<button
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we change the flow of this container to keep these buttons on the same line instead of wrapping to the next line if there isn't enough screen space?

@@ -59,6 +63,41 @@
const workspaceId = getSearchParameterNumber(SearchParameters.WORKSPACE_ID);
goto(`${base}/sequencing/new${workspaceId ? `?${SearchParameters.WORKSPACE_ID}=${workspaceId}` : ''}`);
}

async function importLibarySequences(): Promise<void> {
const workspaceId = getSearchParameterNumber(SearchParameters.WORKSPACE_ID);
Copy link
Collaborator

Choose a reason for hiding this comment

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

workspaceId already exists in the component as a state variable. Can we use that instead of fetching it from the URL again?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for pointing that out

async function importLibarySequences(): Promise<void> {
const workspaceId = getSearchParameterNumber(SearchParameters.WORKSPACE_ID);
if (workspaceId === null) {
console.log("Workspace doesn't exist");
Copy link
Collaborator

Choose a reason for hiding this comment

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

Our current convention for most complicated modals is to call them from an effects function as well as showing toasts. Would you mind moving this into one?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ahhh, got it. I moved part of this function to the effects.ts

if (confirm && value) {
const fileName = await value.libraryFile.name;
const type = fileName.slice(fileName.lastIndexOf('.') + 1);
if (type !== 'satf') {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Are files that contain satf code, but don't have the extension on it allowed? If the file extension is required, then you can specify valid file extensions to disallow unsupported files from even being selected also.

Copy link
Contributor Author

@goetzrrGit goetzrrGit Jan 22, 2025

Choose a reason for hiding this comment

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

Good point. I add accept=".satf" to only allow for satfs to be imported. From what I have seen these files are always appended with .satf

showFailureToast('Library Import: Unsupported file type');
return;
}
const contents = await value.libraryFile.text();
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think you might need to add a try/catch for if it's unable to read the file.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Got it I added a try-catch

: 'UNKNOWN';
default:
throw Error(`unknown argument type ${parameter.type}`);
console.log(`Unknown argument type ${parameter.type}`);
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think the util file should not be in charge of logging. It would be more reusable if the consuming functions using this function are responsible for how they report errors.

Copy link
Contributor Author

@goetzrrGit goetzrrGit Jan 22, 2025

Choose a reason for hiding this comment

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

Got it. I removed the logging. It is returning a value with an error so it stand out to the users that the variable type is incorrect.

The issues is the auto-complete feature for variables will attempts to fill in values for the user by default. These values are coming from a parent sequence file being invoked or called by the @ACTIVATE or @LOAD directive . If there is an issue I still want to display valid parameters.

ex.
C @ACTIVATE("SEQ1") 1 "hello" ERROR:tempurture FALSE

Before the autocomplete will fail and the user will not see any arguments. In order to see what these argument are the user will have to open "SEQ1" in a new tab. Also it lets them know that SEQ1 has an issue so go fix it.

const fileName = await value.libraryFile.name;
const type = fileName.slice(fileName.lastIndexOf('.') + 1);
if (type !== 'satf') {
console.log(`Unsupported file type ${type}`);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do we need to log here if we're already showing the toast?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nope, just for debugging. I removed it.

This modal allows you to select a parcel and import a library sequence file
The linter incorrectly reported errors for values within a valid range when multiple ranges were defined. For example, if the ranges were 5-10 and 11-20, the linter would erroneously flag the value 8 as invalid because it falls outside the 11-20 range, even though it is valid within the 5-10 range.
…invalid variable types.

Allow autocomplete to succeed and show the ERROR parameter value. The user will see this error in the editor and manually have to fix it.
The linter will complain if there is a command with no arguments even though the command itself doesn't have any argument defined in the command dictionary.
There shouldn't be any parenthesis and commas in the SeqN generation
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request sequencing Anything related to the sequencing domain
Projects
Status: Todo
Development

Successfully merging this pull request may close these issues.

Import SATF Library Sequences Prototype
3 participants