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

TASK-6442 - Add Resources Management functionality #2535

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

Conversation

pfurio
Copy link
Member

@pfurio pfurio commented Dec 10, 2024

No description provided.

jtarraga and others added 30 commits October 3, 2024 15:01
…alyisis resources for the current OpenCGA version, and generate clients, #TASK-7088, #TASK-6442
…o the installation folder, #TASK-7088, #TASK-6442
…lization, and add the flag fetchResourceOnInit in the configuration file, #TASK-7088, #TASK-6442
…ng the ResourceManager, #TASK-7139, #TASK-6442
pfurio and others added 26 commits December 10, 2024 16:10
@jtarraga jtarraga requested a review from j-coll December 20, 2024 09:30
Copy link
Member

@j-coll j-coll left a comment

Choose a reason for hiding this comment

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

Review WIP

@@ -60,12 +72,12 @@ public Analysis setScratchDir(String scratchDir) {
return this;
}

public String getResourceUrl() {
return resourceUrl;
public Resource getResource() {
Copy link
Member

Choose a reason for hiding this comment

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

Do not replace old parameters like this. Instead, keep the old methods as "deprecated" and add a call to "Configuration#reportUnusedField"


public static Path getToolResourcePath(String resourceId, Configuration configuration) throws ToolException {
// Get resources from the configuration file
for (ResourceFile resourceFile : configuration.getAnalysis().getResource().getFiles()) {
Copy link
Member

Choose a reason for hiding this comment

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

configuration analysis.resource is a new field in the configuration file. It might be null when upgrading from old versions.
Either add a non-null check, or a migration that ensures that the field is correctly defined (where it would only check for the value, and fail until manually fixed)

logger.warn("Variant {} (normalizedToTsv {}), not found in map variantTranscriptMap", variant.toStringSimple(),
normalizedToTsv.get(variant.toStringSimple()));
logger.warn("Variant {} (normalizedToTsv {}), not found in map variantTranscriptMap",
variant != null ? variant.toStringSimple() : null,
Copy link
Member

Choose a reason for hiding this comment

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

Why variant.toStringSimple() and not variant.toString() ??
You might get duplicated values with the first one


private void loadConfiguration() throws IOException {
if (configuration == null) {
this.configuration = Configuration.load(new FileInputStream(openCgaHome.resolve(CONF_DIRNAME)
Copy link
Member

Choose a reason for hiding this comment

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

FileInputStream not being closed

Copy link
Member

Choose a reason for hiding this comment

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

Better use ConfigurationUtils.loadConfiguration


protected static Logger logger = LoggerFactory.getLogger(ResourceManager.class);

public ResourceManager(Path openCgaHome) {
Copy link
Member

Choose a reason for hiding this comment

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

Why not having a builder with both opencgaHome and the configuration?

Copy link
Member

Choose a reason for hiding this comment

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

Most of the places (all that I've checked) calling this method do already have access to a configuration instance.

@@ -72,6 +72,8 @@ public class UploadCommandOptions {
+ "removed", arity = 0)
public boolean replace;

@Parameter(names = {"--resource"}, description = "File resource", arity = 1)
Copy link
Member

Choose a reason for hiding this comment

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

Use ParamConstants.FILE_RESOURCE_DESCRIPTION

Copy link
Member

Choose a reason for hiding this comment

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

or, at least, its latest value

@@ -291,7 +291,8 @@ public class FieldConstants {
public static final String FILE_CHECKSUM = "The checksum of the file.";
public static final String FILE_PATH = "The path of the file.";
public static final String FILE_URI = "The uri of the file.";
public static final String FILE_EXTERNAL = "Indicates the file is external or not.";
public static final String FILE_EXTERNAL = "Indicates whether the file comes from an external path or not.";
public static final String FILE_RESOURCE = "Indicates the file is treated as a resource.";
Copy link
Member

Choose a reason for hiding this comment

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

Isn't this param almost identical to the ParamConstant "FILE_RESOURCE_DESCRIPTION" ? Why?

protected void run() throws Exception {
MongoCollection<Document> fileCollection = getMongoCollection(OrganizationMongoDBAdaptorFactory.FILE_COLLECTION);

queryMongo(OrganizationMongoDBAdaptorFactory.STUDY_COLLECTION, new Document(),
Copy link
Member

Choose a reason for hiding this comment

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

No migration test?

FqnUtils.FQN fqn = FqnUtils.parse(study.getFqn());
String organization = fqn.getOrganization();
try {
URI studyUri = ioManager.getStudyUri(organization, Long.toString(project.getUid()), Long.toString(study.getUid()));
Copy link
Member

Choose a reason for hiding this comment

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

Understand...
I'd recommend creating a ticket to keep track of this, something like:
"Expose transactions API and remove IOManager from DBAdaptors"
The exposed transactions API should be only for internal use from the Managers, never from outside

@@ -588,10 +585,16 @@ public OpenCGAResult<File> create(String studyStr, FileCreateParams createParams
ParamUtils.checkParameter(createParams.getPath(), "path");
ParamUtils.checkObj(createParams.getType(), "type");

boolean isResource = createParams.getResource() != null && createParams.getResource();
Copy link
Member

Choose a reason for hiding this comment

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

works the same and slightly shorter if you do createParams.getResource() == Boolean.TRUE

@@ -26,13 +26,13 @@ public class AnalysisTool {
private boolean defaultVersion;
private String dockerId;
private String params;
private Map<String, String> resources;
private List<String> resources;
Copy link
Member

Choose a reason for hiding this comment

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

This change will be problematic.. Should be well documented in the changelog

Copy link
Member

Choose a reason for hiding this comment

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

I'm definitely sure that we should have some sort of "configuration changes validation/migration" to ensure that we're not running with old non-migrated versions of the configuration.yml

@@ -3443,6 +3523,10 @@ private OpenCGAResult<File> privateLink(String organizationId, Study study, File
params.setPath(params.getPath() + "/");
}
}
if (isResourcesPath(params.getPath())) {
throw new CatalogException("Linked files cannot be stored in the RESOURCES folder.");
Copy link
Member

Choose a reason for hiding this comment

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

a Resource file can be uploaded but not linked? Why?

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

Successfully merging this pull request may close these issues.

4 participants