-
Notifications
You must be signed in to change notification settings - Fork 98
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
base: develop
Are you sure you want to change the base?
Conversation
…ASK-7047, #TASK-6442
…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
… #TASK-7088, #TASK-6442
…-7088, #TASK-6442
…ing, #TASK-7125, #TASK-6442
…esource management, #TASK-7127, #TASK-6442
…me some constants, #TASK-7088, #TASK-6442
…ng the ResourceManager, #TASK-7139, #TASK-6442
…changes, #TASK-7139, #TASK-6442
…K-7125, #TASK-6442
…hanges, #TASK-7127, #TASK-6442
…anges, #TASK-7088, #TASK-6442
…-7088, #TASK-6442
…tion file according, #TASK-7125, #TASK-6442
There was a problem hiding this 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() { |
There was a problem hiding this comment.
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()) { |
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FileInputStream not being closed
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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."; |
There was a problem hiding this comment.
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(), |
There was a problem hiding this comment.
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())); |
There was a problem hiding this comment.
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(); |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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."); |
There was a problem hiding this comment.
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?
No description provided.