Skip to content

Fb sample type export fixes#1946

Merged
labkey-klum merged 5 commits into
developfrom
fb_sample_type_export_fixes
Feb 2, 2021
Merged

Fb sample type export fixes#1946
labkey-klum merged 5 commits into
developfrom
fb_sample_type_export_fixes

Conversation

@labkey-klum

Copy link
Copy Markdown
Contributor

Rationale

In order to address some recent issues with sample type and data class export/import we have been reconsidering the roles that the XAR and query update service play. In the current design, rows that represent derivation or lineage are captured in the XAR format and all other rows are captured as TSV data. In this PR we pivot so that all rows are exported/imported as TSV, this will happen first and allows any special handling that the QUS may provide on all rows. The XAR handlers will then just be responsible for wiring up and creating derivation runs but will not be tasked with creating materials or datas.

Related issues:

  • 42359: SampleTypeFolderExportImportTest.testExportImportDerivedSamples on sqlserver
  • 42356: Folder import fails when there is an existing sample type of the same name
  • 42161: Unable to import Data Classes as inputs/outputs for Sample Types

Changes

  • Allow for creation of 2 XAR files, one for the sample type and data class definitions and another to represent any derivation protocol runs
  • Export/import all rows via TSV
  • Make XarReader a bit smarter about resolving existing sample types or data classes
  • Add XarImportContext to share XAR related settings between folder importers

# Conflicts:
#	experiment/src/org/labkey/experiment/samples/SampleTypeAndDataClassFolderImporter.java
#	experiment/src/org/labkey/experiment/xar/FolderXarImporterFactory.java
@github-actions

Copy link
Copy Markdown

WARNING: This PR appears to have the default title generated by GitHub. Please use something more descriptive.

if (expData == null && expDataClass != null)
{
// Try resolving it by name within the data class in case we have it under a different LSID
ExpData data = expDataClass.getData(getContainer(), xbData.getName());

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Should be able to avoid this instanceof by using ExperimentServiceImpl to fetch a ExpDataClassImpl. Its getData() returns a ExpDataImpl

ExpData data = (ExpData)o;
if (data.getDataFileUrl() == null)
// Most DataClass data don't have a dataFileUrl, but some do -- like NucSequence imported from a genbank file
// UNDONE: Don't have user and fetching DataClass is expensive-ish. Maybe add data.hasDataClass() or something

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Are these UNDONEs intended to stay here?

@labkey-klum labkey-klum merged commit a8a6078 into develop Feb 2, 2021
@labkey-klum labkey-klum deleted the fb_sample_type_export_fixes branch February 2, 2021 21:12

@labkey-kevink labkey-kevink left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This looks good but I think we need another pass to clear up some of the UNDONE comments.

{
// UNDONE: Now that "Data" prefix is used for DataClass, the AutoFileLSID is not a good default.
// UNDONE: Can we be more restrictive about which LSIDs this is applied to? Maybe only if the objectId part of the LSID includes a "/" (%2F) or something?
// UNDONE: Maybe there is a better way to detect when we should use ${AutoFileLSID}?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@labkey-jeckels Any thoughts about these comments? We don't want to use ${AutoFileLSID} for DataClass data and I don't think we have enough context from the LSID alone to know if it is an exp.data for a file or a DataClass.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I don't know what the DataClass LSIDs look like, but maybe we should build out RelativizedLSIDs.relativize(ExpObject) so that we can use more of the ExpData to help sniff the right approach (checking for a DataFileURL, for example).

public XarExporter(LSIDRelativizer.RelativizedLSIDs relativizedLSIDs, URLRewriter urlRewriter, User user)
{
_relativizedLSIDs = new LSIDRelativizer.RelativizedLSIDs(lsidRelativizer);
// UNDONE: Is it ok to share the relativizedLSIDs across XarExporters and tsv writers?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It seems ok


private String relativizeLSIDPropertyValue(String value, SimpleTypeNames.Enum type)
{
{// NOTE: this is interesting - we fixup LSID values in the xar xml

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

comment was a note to self. remove comment


if (exportXar)
// UNDONE: The other exporters use FOLDER_RELATIVE, but it wants to use ${AutoFileLSID} replacements for DataClass LSIDs when exporting the TSV data.. see comment in ExportLsidDataColumn
LSIDRelativizer.RelativizedLSIDs relativizedLSIDs = new LSIDRelativizer.RelativizedLSIDs(LSIDRelativizer.FOLDER_RELATIVE);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think the relativizedLSIDs instance should be shared across all of the exporters by stashing it in the ImportContext<FolderDocument.Folder>

cnathe added a commit that referenced this pull request Jun 23, 2026
#### Rationale
LabKey/kanban#1946
Encoding updates for data class search template.
Encoding updates for issue resolution in summary.
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.

3 participants