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

Petab download and upload #6

Merged
merged 11 commits into from
Jul 24, 2024
Merged

Conversation

wow-such-code
Copy link
Member

No description provided.

@wow-such-code wow-such-code requested a review from a team as a code owner July 23, 2024 16:42
Copy link

@Steffengreiner Steffengreiner left a comment

Choose a reason for hiding this comment

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

Heya @wow-such-code ! Awesome work. Maybe you can showcase it to me later and address the NITs and questions i have just to ensure that i understood it correctly 👍


import com.fasterxml.jackson.annotation.JsonProperty;

public class IdWithPattern {

Choose a reason for hiding this comment

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

If the id has a pattern does it make sense to check for the pattern during generation?

Copy link
Member Author

Choose a reason for hiding this comment

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

once we know more about it, yes

System.out.println();
System.out.println("Reference datasets found, uploading dataset...");
System.out.println();
//TODO copy and remove source references here

Choose a reason for hiding this comment

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

You still have stuff "ToDo" ;)

Suggested change
//TODO copy and remove source references here
//TODO copy and remove source references here

Comment on lines +26 to +27
//@Option(arity = "1..*", paramLabel = "<parent_datasets>", description = "Optional list of dataset codes to act"
// + " as parents for the upload. E.g. when this dataset has been generated using these datasets as input.", names = {"-pa", "--parents"})

Choose a reason for hiding this comment

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

Why was this commented out? Can this be removed?

Copy link
Member Author

Choose a reason for hiding this comment

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

the ids are now provided via the yaml file, but there might be feedback that this option is better

Comment on lines 32 to 49
while (true) {
String line = reader.readLine();
if (line == null) {
break;
}
if(inIDBlock && line.contains(":")) {
inIDBlock = false;
}
if(inIDBlock) {
String[] tokens = line.split("-");
if(tokens.length == 3) {
String datasetCode = tokens[1].strip()+"-"+tokens[2].strip();
sourcePetabReferences.add(datasetCode);
}
}
if (line.contains("openBISSourceIds:")) {
inIDBlock = true;
}

Choose a reason for hiding this comment

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

I think this section would benefit greatly from a small refactor into distinct methods that outline why the steps are taken for each if clause. Additionally these methods can more easily specify what happens if the input is malformed (token length != 3, why is the inIdBlock set to true even though it could be previously set to false etc.)

Comment on lines +23 to +26
File directory = new File(dataPath);
List<String> sourcePetabReferences = new ArrayList<>();

File yaml = findYaml(directory);

Choose a reason for hiding this comment

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

NIT: Maybe having a distinct exit condition makes sense? If a yaml was provided but is empty, this currently will return a PetabMetadata object with empty metadata, which could be confusing 🤔

Copy link
Member Author

Choose a reason for hiding this comment

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

Currently only parent references are stored in the metadata and those can be empty, which is checked in the respective command.

return;
}
DatasetWithProperties result = new DatasetWithProperties(datasets.get(0));
Optional<String> patientID = openbis.findPropertyInSampleHierarchy("PATIENT_DKFZ_ID",

Choose a reason for hiding this comment

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

Can this be assumed as always present? Maybe it makes sense to move this into a constant at the top of the class?

Copy link
Member Author

Choose a reason for hiding this comment

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

this is currently not used, we need more feedback first

DatasetWithProperties result = new DatasetWithProperties(datasets.get(0));
Optional<String> patientID = openbis.findPropertyInSampleHierarchy("PATIENT_DKFZ_ID",
result.getExperiment().getIdentifier());
patientID.ifPresent(s -> result.addProperty("patientID", s));

Choose a reason for hiding this comment

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

If multiple properties will be set a distinct mapping could also make sense down the line (via an Enum e.g.)

Comment on lines +5 to +14
public class Time {
@JsonProperty
String unit;

@Override
public String toString() {
return "Time{" +
"unit='" + unit + '\'' +
'}';
}

Choose a reason for hiding this comment

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

Shouldn't this also have a value, or is this only the unit specification?

Copy link
Member Author

Choose a reason for hiding this comment

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

one would think so, but the example yaml only has unit

Path path = Paths.get(Objects.requireNonNull(findYaml(new File(outputPath))).getPath());
Charset charset = StandardCharsets.UTF_8;

String idInLine = "openBISId:(.*)?(\\r\\n|[\\r\\n])";

Choose a reason for hiding this comment

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

Since you reuse the openBISId: string it might make sense to provide it as a final constant (within this method is more than fine though)

Comment on lines +81 to +82
System.out.println(META_INFO_YAML + " not found");
return null;

Choose a reason for hiding this comment

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

NIT: This currently does not catch the case on what happens if the user provides multiple "metaInformation.yaml" by mistake.

Copy link
Member Author

Choose a reason for hiding this comment

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

good point, I think the most top level yaml with that name should be considered the correct one, as it is now

Copy link

@Steffengreiner Steffengreiner left a comment

Choose a reason for hiding this comment

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

LGTM 🚀

@wow-such-code wow-such-code merged commit f68bb7f into development Jul 24, 2024
3 checks passed
@KochTobi
Copy link
Member

What is this for? Why is this needed? What does this change?

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

Successfully merging this pull request may close these issues.

3 participants