The road towards a Library Sharing MVP #7692
Replies: 2 comments 4 replies
-
RFC @wdanilo @jdunkerley @JaroslavTulach @hubertp My 2 cents:
|
Beta Was this translation helpful? Give feedback.
-
When thinking about the library sharing system, I'd like to mention that it'd be beneficial if the IDE could provide a repository with its own libraries and use them in visualizations. |
Beta Was this translation helpful? Give feedback.
-
We want to allow our users to share their projects as libraries. I will analyze two approaches that we can take to get us to this state in the minimal amount of work - relying on the existing infrastructure we have for this purpose, and listing the things that need to be added.
The workflow we want to support
Ctrl+G
.Only me
) or on the organization level (Organization
). Public sharing could be a next step.Share
d).i. the ability to somehow access libraries the user has 'Published' in the Cloud from within a local Enso installation.
Possible solutions
We have 2 possible approaches we can take to make the workflow described above possible.
Our library resolution system contains two concepts of library sources: local user-editable libraries on the filesystem, and libraries published in a repository. The two solutions rely on either of these systems to provide an MVP.
'Local' solution
Enso is able to automatically include libraries from
$ENSO_HOME/libraries
if thepackage.yaml
containsprefer-local-libraries: true
.In this scenario:
$ENSO_HOME/libraries
(if needed we can have more than one directory for local libraries, we just need to override$ENSO_LIBRARY_PATH
).library/listLocal
endpoint.import <namespace>.<name>
orfrom <namespace>.<name> import all
to theMain.enso
file.This scenario has limited support for sharing a library from Enso Cloud into local Enso installation. To achieve it, we would need the IDE to be able to query libraries available in the cloud 'directory' and download them into the local
$ENSO_HOME/libraries
.'Repository' solution
This uses the dedicated infrastructure for sharing libraries, thus it may require a bit more support but is also much more future proof.
In this scenario:
root/<namespace>/<name>/<version>
(see docs).editions/listDefinedLibraries
.import <namespace>.<name>
orfrom <namespace>.<name> import all
to theMain.enso
file, as long as it is defined in the current edition.The major difference between this and the Local solution is how we discover available libraries. In the Local solution we simply look at what projects are available on the filesystem in directories determined by
ENSO_LIBRARY_PATH
. In this solution, the libraries are determined by the edition and can come from various repositories.What we need to get this working
Common functionality
Both solutions will need some common part in terms of the UI:
data
associated with the project is also published was mentioned);import
statement at the beginning ofMain.enso
).Moreover, both will need some additional support for authentication, especially to support accessing private libraries from the Local installations. We will need to extend the system for downloading libraries to be able to specify additional headers containing any necessary authentication tokens, probably set via environment variables. For that we will need:
'Local' solution
$ENSO_HOME/libraries
(or some other location), used for storing libraries.i. It can provide one or more volumes, e.g. we could have one volume for Personal (Only me) libraries and another one for Organization-level libraries (shared between users). Each of these volumes need to be mounted for each instance run by the user.
ii. If there are more volumes, we need to set
ENSO_LIBRARY_PATH
to allow Enso to discover them.$ENSO_HOME/libraries
when the user clicks 'Publish'.i. either ensure that new projects get
prefer-local-libraries: true
,ii. or change the resolution logic so that even if
prefer-local-libraries: false
, if a library is not found in the edition, a local lookup is still performed (IMO this is better).i. This is extra hacky. I think the Local solution is a great MVP that can be developed very quickly, without this feature. If we want this extra feature though, the 'Repository' solution would be a much better choice IMHO.
'Repository' solution
i. We probably want to have separate buckets for each user and organization, to keep private libraries private.
i. The client-side uploader that handles all necessary packaging is already implemented.
ii. We need some 'other side' to receive these packages.
i. We can use an AWS lambda that would gather libraries available to the particular user (e.g. listing objects in their 'personal' bucket and merging these with the objects available in the user organization's bucket), and generate an edition file from these.
i. The edition file is not meant to be re-loadable during runtime, so the newly added libraries only show up when the project is restarted. This is by design (if the edition file changed a version of a particular library, we would need to unload the old library version and load a new one which is extremely hard to do in a live environment that may already be using this library).
ii. For the longer term, the idea was indeed that editions were supposed to be immutable. But we can easily disable this temporarily. We can also (for future) create a notion of stable editions that are immutable once published, and unstable editions that are expected to be updated and need to be re-downloaded.
i. We first thought that for first version we could keep a pinned
1.0.0
version and overwrite library files.ii. That will not work well, because again - the library system assumes that library versions are immutable. So once a version
1.0.0
of a library is downloaded, it is cached locally and will not be redownloaded unless the cache is manually purged.iii. Thus, I think instead, we should always increment the minor version number when uploading a new version (
1.0.0
,1.0.1
,1.0.2
, ...). For now, our logic for generating the edition file listing libraries available to the user can always look for the highest version number available in the bucket and list that. By increasing the numbers for each new version, we will ensure that the library is re-downloaded when a new version is published.i. Since this solution relies more on downloading libraries thru HTTP; and likely the first version will not retain caches in the cloud (a very useful optimization, but not strictly necessary for MVP), it would be good to notify the user about pending downloads.
ii. All functionality is already there in the Language Server. We would just need the IDE to handle the
task/*
messages (especiallytask/progress-update
) and display some kind of spinner/progress bar indicating the pending action.iii. This is not strictly necessary for the MVP to work, but I think it would be a helpful feature to make the UX better.
Beta Was this translation helpful? Give feedback.
All reactions