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

feat(core): export several util functions #997

Merged
merged 3 commits into from
Dec 4, 2023
Merged

Conversation

sehilyi
Copy link
Member

@sehilyi sehilyi commented Nov 23, 2023

Fix #983

Change List

  • Added several util functions for calculating chromosome positions. This is the first time exposing util functions, and the user API could be changed after discussing with the team.

import { utils } from 'gosling.js';
console.log(utils);
// print
{
getRelativeGenomicPosition,
computeChromSizes,
getChromInterval,
getChromTotalSize,
parseGenomicPosition,
sanitizeChrName
}

import { getRelativeGenomicPosition } from 'gosling.js/utils';

Checklist

  • Ensure the PR works with all demos on the online editor
  • Unit tests added or updated
  • Examples added or updated
  • Documentation updated (e.g., added API functions)
  • Screenshots for visual changes (e.g., new encoding support or UI change on Editor)

@sehilyi sehilyi changed the title feat: export several util functions feat(core): export several util functions Nov 23, 2023
@sehilyi
Copy link
Member Author

sehilyi commented Nov 29, 2023

@manzt Could you review this to see if this makes sense to you? Open to any suggestions regarding how we want to expose utility functions to users.

Copy link
Member

@manzt manzt left a comment

Choose a reason for hiding this comment

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

Looks fine to me. Although I wonder about exporting these under a namespace like _interval for now. What's the plan in versioning Gosling with relation to these utilities going forward? A namespace like _internal or _util might suggest to most users "use with caution" or carry other semantics compared to the rendering logic.

import { _internal } from "gosling.js";

const { getRelativeGenomicPosition } = _internal;

I think ideally we'd have a separate library for these shared utilities in a monorepo (e.g., @gosling-lang/utils) which could be versioned separately from gosling as a whole. That way folks could have that versioned separately. However, in the short term this seems to be a fine solution.

src/index.ts Outdated Show resolved Hide resolved
…y funcs (#1001)

feat: Create separate entrypoint for gosling.js/utils
@sehilyi
Copy link
Member Author

sehilyi commented Nov 30, 2023

Although I wonder about exporting these under a namespace like _interval for now. What's the plan in versioning Gosling with relation to these utilities going forward? A namespace like _internal or _util might suggest to most users "use with caution" or carry other semantics compared to the rendering logic.

@manzt Given that the code has been changed after I merged your update, would you suggest adding _ to all functions? e.g.,

export {
    getRelativeGenomicPosition as _getRelativeGenomicPosition,
    computeChromSizes as _computeChromSizes,
    getChromInterval as _getChromInterval,
    getChromTotalSize as _getChromTotalSize,
    parseGenomicPosition as _parseGenomicPosition
} from './core/utils/assembly';
export { sanitizeChrName as _sanitizeChrName } from './data-fetchers/utils';

I think we want to support the utils functions as a separate library in the future (@gosling-lang/utils), but we have not decided what functions (and in what names) we want to expose to users.

@manzt
Copy link
Member

manzt commented Nov 30, 2023

@manzt Given that the code has been changed after I merged your update, would you suggest adding _ to all functions?

I think it's fine as is (no _). Right now we can say that gosling.js/utils is versioned with gosling.js, and we could make breaking changes to these utilities in minor version changes. In the future, we will hopefully have a separate package with utilities. However, I'd only put uilities that are used across other sub-packages in @gosling-lang/utils, or ones that we want to make avaiablie to end users (like this one).

We should keep utilities which are only used by a given package (e.g., @gosling-lang/core) within that package, unless they are used elsewhere or intended as a part of some public API for end users.

Utilities can be "promoted" to this package if they end up used across projects or by end users, but this "promotion" should come with a consideration of the API and process of making it public.

@sehilyi sehilyi merged commit 7e9a834 into master Dec 4, 2023
5 checks passed
@sehilyi sehilyi deleted the sehilyi/util-export branch December 4, 2023 19:36
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.

Export common functionality
2 participants