Skip to content

Enable multiple git revisions (Jun 2024) : final, using commit ID in repo localPath #5089

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

Open
wants to merge 105 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
105 commits
Select commit Hold shift + click to select a range
7d027ec
Multiple revisions 1st: AssetManager, Cmd Clone Pull Run
marcodelapierre Jan 15, 2024
106e8df
removed revision paramter from clone pull run
marcodelapierre Jan 16, 2024
0a9e6f8
updated unit tests for AssetManager
marcodelapierre Jan 16, 2024
37d332e
Merge branch 'master' into add/mult_revisions
marcodelapierre Jan 16, 2024
5a9b159
AssetManager provider.revision assigned at AssetManager object creation
marcodelapierre Jan 16, 2024
94d34f3
Codespell typo in changelog
marcodelapierre Jan 16, 2024
4744774
AssetManager: removed checkout method
marcodelapierre Jan 16, 2024
d9e7b2b
Merge branch 'master' into add/mult_revisions
marcodelapierre Jan 17, 2024
08718ef
assetmanager: fixed build signature, and unit tests
marcodelapierre Jan 17, 2024
242a600
assetmanager: one more build signature fix
marcodelapierre Jan 17, 2024
35ad1e9
AssetManager: fix for multi revs in find() method
marcodelapierre Jan 17, 2024
463b6f1
Multiple revisions: added for Cmds Drop, View, Config, Info
marcodelapierre Jan 17, 2024
2d3273e
minor fixes to log outputs in CmdRun
marcodelapierre Jan 17, 2024
d2e5ffe
AssetManager: documented new localPath schema
marcodelapierre Jan 18, 2024
60c3c5e
K8sDriverLauncher : added revision support
marcodelapierre Jan 18, 2024
4bf1e37
updates to AssetManagerTest
marcodelapierre Jan 18, 2024
7e32111
edit to AssetManagerTest, git.pull for TAGS does not output result of…
marcodelapierre Jan 18, 2024
3b2d461
minor fix in GitlabRepositoryProvider: using DEFAULT_BRANCH instead o…
marcodelapierre Jan 18, 2024
2e6461e
Minor edits
bentsherman Jan 23, 2024
a8d2dee
Merge branch 'master' into add/mult_revisions
marcodelapierre Feb 5, 2024
eaf45d8
[ci fast] Merge branch 'master' into add/mult_revisions
pditommaso Feb 10, 2024
ed17284
Merge branch 'master' into add/mult_revisions
marcodelapierre Feb 23, 2024
b3f141d
parametrised revision delimiter
marcodelapierre Feb 28, 2024
6706bd9
nf pull: option to list or not revs for each project
marcodelapierre Feb 28, 2024
e62f543
nicer output for nf list -r
marcodelapierre Feb 28, 2024
bd19877
minor edit to CmdList
marcodelapierre Feb 29, 2024
c0268af
AssetManager: adding listRevisions method (work in progress)
marcodelapierre Feb 29, 2024
aae2afc
small tune to CmdList
marcodelapierre Feb 29, 2024
268ec79
minor tweak to CmdList
marcodelapierre Feb 29, 2024
ac8d755
AssetManager: listRevisions method now working
marcodelapierre Feb 29, 2024
70c8bcc
CmdDrop option to drop all revisions of given project
marcodelapierre Feb 29, 2024
8bcd717
AssetManagerTest: added test for method listRevisions
marcodelapierre Mar 4, 2024
4616e7f
docs - cli: add -a options for list and drop
marcodelapierre Mar 4, 2024
e4b9d78
docs - cli: add/update -r option for relevant commands
marcodelapierre Mar 4, 2024
958955a
CmdInfo: now also prints info on pulled revisions
marcodelapierre Mar 4, 2024
f220e98
CmdInfo made smarter when non only non default revisions pulled
marcodelapierre Mar 4, 2024
2ad9a24
CmdInfoTest updated
marcodelapierre Mar 4, 2024
35ea812
CmdInfoTest fix
marcodelapierre Mar 4, 2024
80ecacd
CmdInfo: added code comment
marcodelapierre Mar 4, 2024
5e4b45f
AssetManager: default revision recognised correctly if specified in m…
marcodelapierre Mar 4, 2024
aa94d7b
small CLI Docs update
marcodelapierre Mar 4, 2024
d965ee5
added a couple of comments
marcodelapierre Mar 6, 2024
f6e6174
Merge branch 'master' into add/mult_revisions
marcodelapierre Mar 11, 2024
ca48a97
Merge branch 'master' into add/mult_revisions
pditommaso Mar 17, 2024
12d31a2
fix merge conflicts
marcodelapierre Mar 21, 2024
9aacb2b
Review: REVISION_DELIM and added comments
marcodelapierre Mar 21, 2024
12718c7
review: added method getProjectWithRevision
marcodelapierre Mar 21, 2024
0b57262
updated method getBaseNameWithRevision
marcodelapierre Mar 21, 2024
17067ea
docs/sharing: added paragraph on multiple revisions, with caveat on r…
marcodelapierre Mar 21, 2024
67dc5d5
cmd info: removed sticky current revision, updated docs
marcodelapierre Mar 21, 2024
7716416
fixed unit tests in CmdInfoTest
marcodelapierre Mar 21, 2024
45be84b
Merge branch 'master' into add/mult_revisions
marcodelapierre Apr 4, 2024
2af4ba7
merged from master
marcodelapierre Apr 8, 2024
afa8a1c
Merge branch 'master' into add/mult_revisions
marcodelapierre Apr 12, 2024
dc4bdee
Merge branch 'master' into add/mult_revisions
marcodelapierre Apr 15, 2024
4c93b3e
Merge branch 'master' into add/mult_revisions_apr_revision_path
marcodelapierre Jun 17, 2024
561a59f
docs update/fix
marcodelapierre Jun 17, 2024
48cf800
multi revs: consistent usage of manager.getProjectWithRevision() in Cmds
marcodelapierre Jun 17, 2024
6070273
AssetManager: undo redirect of default revision to null (circular man…
marcodelapierre Jun 17, 2024
da159d9
AssetManager: removed chicken n egg between hubprovider and localpath
marcodelapierre Jun 17, 2024
1824952
AssetManager: new location for revisions
marcodelapierre Jun 17, 2024
c2db132
Using new Asset location for CmdDrop and CmdList
marcodelapierre Jun 17, 2024
32fe348
Using new Asset location for CmdPull
marcodelapierre Jun 18, 2024
8411c2e
CmdDrop and CmdList: got rid of REVISION_DELIM
marcodelapierre Jun 18, 2024
c190dac
Using new Asset location for CmdInfo
marcodelapierre Jun 18, 2024
55868c7
updated CmdClone
marcodelapierre Jun 18, 2024
05ac8c9
AssetManager: reverted to original find() method
marcodelapierre Jun 18, 2024
0dbc77d
fixed revisionSubdir and unit tests
marcodelapierre Jun 18, 2024
e3cfec4
docs updates
marcodelapierre Jun 18, 2024
b6352c4
AssetManager: REVISION_DELIM not needed any more
marcodelapierre Jun 18, 2024
db4903a
AssetManagerTest: further fixes
marcodelapierre Jun 18, 2024
90f8f1d
AssetManager: revert back to set revision in checkValidRemoteRepo()
marcodelapierre Jun 18, 2024
a3d5557
AssetManager: using existing revision map
marcodelapierre Jun 19, 2024
0f29320
using DEFAULT_REVISION_DIRNAME
marcodelapierre Jun 19, 2024
93db4ee
AssetManager: add checkLocalBarePath
marcodelapierre Jun 19, 2024
71a5b2f
rename checkLocalBarePath to checkBareRepo
marcodelapierre Jun 19, 2024
70847e7
AssetManager: added revisionToCommitWithBareRepo, work in progress
marcodelapierre Jun 19, 2024
9c68166
minor update
marcodelapierre Jun 19, 2024
0a3d4a6
AssetManager: updateRevisionMap ok, overall work in progress
marcodelapierre Jun 20, 2024
920f8aa
final updateProjectDir ; fixed cmddrop
marcodelapierre Jun 20, 2024
be2b84f
in localPath, use commitId, plus related fixes in listRevisions
marcodelapierre Jun 20, 2024
8da7bea
list command can also show commits
marcodelapierre Jun 20, 2024
d7c2f30
updated docs/sharing.md commit in localpath
marcodelapierre Jun 20, 2024
f27b115
remove use of getPulledRevisions
marcodelapierre Jun 20, 2024
3d45ef3
fix for CmdDrop: use of DEFAULT_REVISION_DIRNAME
marcodelapierre Jun 20, 2024
06a2229
CmdList: better output for default revision
marcodelapierre Jun 20, 2024
a77bd59
AssetManager, CmdDrop : some method signature updates
marcodelapierre Jun 20, 2024
28fe569
Merge branch 'master' into add/mult_revisions_jun_revision_map
marcodelapierre Jun 24, 2024
3b9978b
AssetManager.download(): using bareRepo for pulling, plus related cha…
marcodelapierre Jun 24, 2024
20e6edc
CmdList and CmdPull: no need for manager.close()
marcodelapierre Jun 24, 2024
2199974
AssetManagerTest: updated list tests
marcodelapierre Jun 24, 2024
36dab4d
AssetManagerTest: fixed manifest test 1
marcodelapierre Jun 24, 2024
2375bda
AssetManagerTest: fixed all executed tests
marcodelapierre Jun 24, 2024
ae835e8
CmdPullTest fixed
marcodelapierre Jun 24, 2024
6769307
AssetManagerTest: fixed tests that need github token
marcodelapierre Jun 24, 2024
2cf9942
AssetManagerTest: add test for checkBareRepo
marcodelapierre Jun 24, 2024
0c140de
AssetManagerTest: added various tests for revToCommit methods
marcodelapierre Jun 25, 2024
923e200
AssetManagerTest: updated listRevs tests
marcodelapierre Jun 25, 2024
bac8797
AssetManager: update to revisionToCommitWithBareRepo
marcodelapierre Jun 25, 2024
5de01cc
AssetManagerTest: removed unneeded variable
marcodelapierre Jun 25, 2024
b061203
UpdateModuleTest: small makeup
marcodelapierre Jun 25, 2024
5a81758
UpdateModuleTest: fixed all unit tests
marcodelapierre Jun 25, 2024
3052994
UpdateModuleTest: minor edit
marcodelapierre Jun 25, 2024
6d6d7ae
AssetManager: set revision and localPath outside constructor as separ…
marcodelapierre Jun 25, 2024
69416fc
CmdPull: allow -a as equivalent to -all
marcodelapierre Jun 25, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 25 additions & 7 deletions docs/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ The `clone` command downloads a pipeline from a Git-hosting platform into the *c
: Service hub where the project is hosted. Options: `gitlab` or `bitbucket`.

`-r` (`master`)
: Revision to clone - It can be a git branch, tag, or revision number.
: Revision of the project to clone (either a git branch, tag or commit SHA number).

`-user`
: Private repository user name.
Expand Down Expand Up @@ -415,6 +415,9 @@ The `config` command is used for printing the project's configuration i.e. the `
`-properties`
: Print config using Java properties notation.

`-r, -revision`
: Revision of the project (either a git branch, tag or commit SHA number).

`-a, -show-profiles`
: Show all configuration profiles.

Expand Down Expand Up @@ -535,12 +538,18 @@ The `drop` command is used to remove the projects which have been downloaded int

**Options**

`-a, -all-revisions`
: For specified project, drop all revisions.

`-f`
: Delete the repository without taking care of local changes.

`-h, -help`
: Print the command usage.

`-r, -revision`
: Revision of the project to drop (either a git branch, tag or commit SHA number).

**Examples**

Drop the `nextflow-io/hello` project.
Expand Down Expand Up @@ -664,7 +673,7 @@ $ nextflow info [options] [project]

**Description**

The `info` command prints out the nextflow runtime information about the hardware as well as the software versions of the Nextflow version and build, operating system, and Groovy and Java runtime. It can also be used to display information about a specific project.
The `info` command prints out the nextflow runtime information about the hardware as well as the software versions of the Nextflow version and build, operating system, and Groovy and Java runtime. It can also be used to display information about a specific project; in this case, note how revisions marked as `P` are pulled locally.

If no run name or session id is provided, it will clean the latest run.

Expand Down Expand Up @@ -706,10 +715,10 @@ $ nextflow info nextflow-io/hello
local path : /Users/evanfloden/.nextflow/assets/nextflow-io/hello
main script : main.nf
revisions :
* master (default)
P master (default)
mybranch
testing
v1.1 [t]
P v1.1 [t]
v1.2 [t]
```

Expand Down Expand Up @@ -878,6 +887,12 @@ The `list` commands prints a list of the projects which are already downloaded i

**Options**

`-a, -all-revisions`
: For each project, also list revisions.

`-d`
: Show commit information for revisions (in conjunction with `-a`)).

`-h, -help`
: Print the command usage.

Expand Down Expand Up @@ -1059,7 +1074,7 @@ The `pull` command downloads a pipeline from a Git-hosting platform into the glo

**Options**

`-all`
`-a, -all`
: Update all downloaded projects.

`-d, -deep`
Expand All @@ -1072,7 +1087,7 @@ The `pull` command downloads a pipeline from a Git-hosting platform into the glo
: Service hub where the project is hosted. Options: `gitlab` or `bitbucket`

`-r, -revision`
: Revision of the project to run (either a git branch, tag or commit hash).
: Revision of the project to pull (either a git branch, tag or commit SHA number).
: When passing a git tag or branch, the `workflow.revision` and `workflow.commitId` fields are populated. When passing only the commit hash, `workflow.revision` is not defined.

`-user`
Expand Down Expand Up @@ -1217,7 +1232,7 @@ The `run` command is used to execute a local pipeline script or remote pipeline
: Execute the script using the cached results, useful to continue executions that was stopped by an error.

`-r, -revision`
: Revision of the project to run (either a git branch, tag or commit hash).
: Revision of the project to run (either a git branch, tag or commit SHA number).
: When passing a git tag or branch, the `workflow.revision` and `workflow.commitId` fields are populated. When passing only the commit hash, `workflow.revision` is not defined.

`-stub-run, -stub`
Expand Down Expand Up @@ -1426,6 +1441,9 @@ The `view` command is used to inspect the pipelines that are already stored in t
`-q`
: Hide header line.

`-r, -revision`
: Revision of the project (either a git branch, tag or commit SHA number).

**Examples**

Viewing the contents of a downloaded pipeline.
Expand Down
3 changes: 2 additions & 1 deletion docs/developer/diagrams/nextflow.scm.mmd
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@ classDiagram

class AssetManager {
project : String
revision : String
localPath : File
mainScript : String
repositoryProvider : RepositoryProvider
provider : RepositoryProvider
hub : String
providerConfigs : List~ProviderConfig~
}
Expand Down
17 changes: 13 additions & 4 deletions docs/sharing.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,15 @@ nextflow run nextflow-io/hello -r v1.1

It will execute two different project revisions corresponding to the Git tag/branch having that names.

:::{versionadded} 24.XX.0-edge
:::

Nextflow downloads and locally maintains each explicitly requested Git branch, tag or commit ID in a separate directory path, thus enabling to run multiple revisions of the same pipeline at the same time. Each downloaded revision is stored in a subdirecrory path of the local project path: `$NXF_ASSETS/<org>/<repo>/.nextflow/commits/<commitId>`.

:::{warning}
If you really care about reproducibility of your pipelines, consider explicitly referring to them by tag or commit ID, rather than my branch. This is because the same branch will point to different underlying commits over time, as pipeline development goes on.
:::

## Commands to manage projects

The following commands allows you to perform some basic operations that can be used to manage your projects.
Expand Down Expand Up @@ -91,16 +100,16 @@ By using the `info` command you can show information from a downloaded project.
$ nextflow info hello
project name: nextflow-io/hello
repository : http://github.com/nextflow-io/hello
local path : $HOME/.nextflow/assets/nextflow-io/hello
local path : /Users/evanfloden/.nextflow/assets/nextflow-io/hello
main script : main.nf
revisions :
* master (default)
P master (default)
mybranch
v1.1 [t]
P v1.1 [t]
v1.2 [t]
```

Starting from the top it shows: 1) the project name; 2) the Git repository URL; 3) the local folder where the project has been downloaded; 4) the script that is executed when launched; 5) the list of available revisions i.e. branches and tags. Tags are marked with a `[t]` on the right, the current checked-out revision is marked with a `*` on the left.
Starting from the top it shows: 1) the project name; 2) the Git repository URL; 3) the local path where the project can be found; 4) the script that is executed when launched; 5) the list of available revisions i.e. branches and tags. Tags are marked with a `[t]` on the right, the locally pulled revisions are marked with a `P` on the left.

### Pulling or updating a project

Expand Down
10 changes: 6 additions & 4 deletions modules/nextflow/src/main/groovy/nextflow/cli/CmdClone.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/

package nextflow.cli

import com.beust.jcommander.Parameter
import com.beust.jcommander.Parameters
import groovy.transform.CompileStatic
Expand All @@ -37,7 +38,7 @@ class CmdClone extends CmdBase implements HubOptions {
@Parameter(required=true, description = 'name of the project to clone')
List<String> args

@Parameter(names='-r', description = 'Revision to clone - It can be a git branch, tag or revision number')
@Parameter(names='-r', description = 'Revision of the project to clone (either a git branch, tag or commit SHA number)')
String revision

@Parameter(names=['-d','-deep'], description = 'Create a shallow clone of the specified depth')
Expand All @@ -53,6 +54,7 @@ class CmdClone extends CmdBase implements HubOptions {
// the pipeline name
String pipeline = args[0]
final manager = new AssetManager(pipeline, this)
manager.setRevisionAndLocalPath(pipeline, revision)

// the target directory is the second parameter
// otherwise default the current pipeline name
Expand All @@ -68,9 +70,9 @@ class CmdClone extends CmdBase implements HubOptions {
}

manager.checkValidRemoteRepo()
print "Cloning ${manager.project}${revision ? ':'+revision:''} ..."
manager.clone(target, revision, deep)
print "Cloning ${manager.getProjectWithRevision()} ..."
manager.clone(target, deep)
print "\r"
println "${manager.project} cloned to: $target"
println "${manager.getProjectWithRevision()} cloned to: $target"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ class CmdConfig extends CmdBase {
@Parameter(description = 'project name')
List<String> args = []

@Parameter(names=['-r','-revision'], description = 'Revision of the project (either a git branch, tag or commit SHA number)')
String revision

@Parameter(names=['-a','-show-profiles'], description = 'Show all configuration profiles')
boolean showAllProfiles

Expand Down Expand Up @@ -184,6 +187,7 @@ class CmdConfig extends CmdBase {
}

final manager = new AssetManager(path)
manager.setRevisionAndLocalPath(path, revision)
manager.isLocal() ? manager.localPath.toPath() : manager.configFile?.parent

}
Expand Down
50 changes: 41 additions & 9 deletions modules/nextflow/src/main/groovy/nextflow/cli/CmdDrop.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

package nextflow.cli

import static nextflow.scm.AssetManager.DEFAULT_REVISION_DIRNAME

import com.beust.jcommander.Parameter
import com.beust.jcommander.Parameters
import groovy.transform.CompileStatic
Expand All @@ -39,6 +41,12 @@ class CmdDrop extends CmdBase {
@Parameter(required=true, description = 'name of the project to drop')
List<String> args

@Parameter(names=['-r','-revision'], description = 'Revision of the project to drop (either a git branch, tag or commit SHA number)')
String revision

@Parameter(names=['-a','-all-revisions'], description = 'For specified project, drop all revisions')
Boolean allRevisions

@Parameter(names='-f', description = 'Delete the repository without taking care of local changes')
boolean force

Expand All @@ -48,18 +56,42 @@ class CmdDrop extends CmdBase {
@Override
void run() {
Plugins.init()
def manager = new AssetManager(args[0])
if( !manager.localPath.exists() ) {
throw new AbortOperationException("No match found for: ${args[0]}")

List<AssetManager> dropList = []
if ( allRevisions ) {
def revManager = new AssetManager(args[0])
revManager.listRevisions().each { rev ->
if( rev == DEFAULT_REVISION_DIRNAME )
rev = null
dropList << new AssetManager(args[0]).setRevisionAndLocalPath(args[0], rev)
}
} else {
dropList << new AssetManager(args[0]).setRevisionAndLocalPath(args[0], revision)
}

if( this.force || manager.isClean() ) {
manager.close()
if( !manager.localPath.deleteDir() )
throw new AbortOperationException("Unable to delete project `${manager.project}` -- Check access permissions for path: ${manager.localPath}")
return
if ( !dropList ) {
throw new AbortOperationException("No revisions found for specified project: ${args[0]}")
}

throw new AbortOperationException("Local project repository contains uncommitted changes -- won't drop it")
dropList.each { manager ->
if( !manager.localPathDefinedAndExists() ) {
throw new AbortOperationException("No match found for: ${manager.getProjectWithRevision()}")
}

if( this.force || manager.isClean() ) {
manager.close()
if( !manager.localPath.deleteDir() )
throw new AbortOperationException("Unable to delete project `${manager.getProjectWithRevision()}` -- Check access permissions for path: ${manager.localPath}")
manager.pruneRevisionMap(manager.revision)
return
}

throw new AbortOperationException("Local project repository contains uncommitted changes -- won't drop it")
}

if ( allRevisions ) {
def revManager = new AssetManager(args[0])
revManager.localRootPath.deleteDir()
}
}
}
21 changes: 16 additions & 5 deletions modules/nextflow/src/main/groovy/nextflow/cli/CmdInfo.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,20 @@ class CmdInfo extends CmdBase {
}

Plugins.init()
final manager = new AssetManager(args[0])
if( !manager.isLocal() )
throw new AbortOperationException("Unknown project `${args[0]}`")
def manager = new AssetManager(args[0])
manager.setRevisionAndLocalPath(args[0], null)
if( !manager.isLocal() ) {
// if default branch not found locally, use first one from list of local pulls
if ( manager.listRevisions() ) {
manager = new AssetManager(args[0])
manager.setRevisionAndLocalPath(args[0], manager.listRevisions()[0])
if( !manager.isLocal() )
throw new AbortOperationException("Unknown project `${args[0]}`")
}
else {
throw new AbortOperationException("Unknown project `${args[0]}`")
}
}

if( !format || format == 'text' ) {
printText(manager,level)
Expand All @@ -101,7 +112,7 @@ class CmdInfo extends CmdBase {

out.println " project name: ${manager.project}"
out.println " repository : ${manager.repositoryUrl}"
out.println " local path : ${manager.localPath}"
out.println " local path : ${manager.localRootPath.toString()}"
out.println " main script : ${manager.mainScriptName}"
if( manager.homePage && manager.homePage != manager.repositoryUrl )
out.println " home page : ${manager.homePage}"
Expand Down Expand Up @@ -138,7 +149,7 @@ class CmdInfo extends CmdBase {
def result = [:]
result.projectName = manager.project
result.repository = manager.repositoryUrl
result.localPath = manager.localPath?.toString()
result.localPath = manager.localRootPath.toString()
result.manifest = manager.manifest.toMap()
result.revisions = manager.getBranchesAndTags(checkForUpdates)
return result
Expand Down
Loading
Loading