-
Notifications
You must be signed in to change notification settings - Fork 26
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
Generation of new IDs for entities #312
Generation of new IDs for entities #312
Comments
From my perspective, the user should be guided about giving the title to the dataset (e.g. limited lenght of the title, reference to version, date of the dataset). The |
After feedback gathering with @edobrowolska and @aapopescu, the second option (UUID) is the preferred one. |
There is a doubt arising, since an enforcement/validation of the UUID format would cause all existing entities to be invalid; see discussion at ESA-EarthCODE/open-science-catalog-validation#18 |
I find UUIDs very user unfriendly, especially as they bubble up to the user through the various osc: fields, e.g. Here's example code how a unique ID could be generated based on a given folder (assuming git-clerk does it on the server-side): const fs = require('fs');
const path = require('path');
const FOLDER = './projects';
const TITLE = 'polaris';
function slugify(value) {
return String(value)
.replace(/[^a-z0-9]+/gi, '-') // Replace all sequences of non-alphanumeric characters with a dash
.replace(/^-+|-+$/g, '') // Trim leading/trailing dashes
.toLowerCase();
}
function generateId(folder, title, childFileName) {
let slug = slugify(title);
let i = 2;
let id = slug;
while (fs.existsSync(path.join(folder, id, childFileName))) { // this should be made async in production
id = slug + '-' + i++;
}
return id;
}
console.log(generateId(FOLDER, TITLE, 'collection.json'));
// Generates e.g. polaris-2 as ID is polaris already exists |
I tend to agree with you @m-mohr and changed the ids in the new workflow and experiment examples accordingly. |
Currently, contributors are required to add an
id
manually to files; this is prone to errors as the ID could e.g. be not unique. As a remedy, we should auto-generate IDs on behalf of the contributor. Possible options:id
fromtitle
property:title
is later changed, theid
might diverge substantially from it, possibly causing confusionid
randomly (UUID):In general, we should remind ourselves that the way to browse the catalog is by using the OSC GUI (powered by STAC Browser) and not the repository itself - this might influence our decision.
The text was updated successfully, but these errors were encountered: