[Notes] [Git][BuildStream/buildstream][jennis/migrate_pull_push_commands] WIP: Ensure push/pull can deal with artifact refs



Title: GitLab

James Ennis pushed to branch jennis/migrate_pull_push_commands at BuildStream / buildstream

Commits:

1 changed file:

Changes:

  • buildstream/_frontend/cli.py
    ... ... @@ -944,7 +944,6 @@ def _classify_artifacts(names, cas, project_directory):
    944 944
         return targets, refs
    
    945 945
     
    
    946 946
     
    
    947
    -
    
    948 947
     @cli.group(short_help="Manipulate cached artifacts")
    
    949 948
     def artifact():
    
    950 949
         """Manipulate cached artifacts"""
    
    ... ... @@ -959,10 +958,9 @@ def artifact():
    959 958
                   help='The dependency artifacts to pull (default: none)')
    
    960 959
     @click.option('--remote', '-r',
    
    961 960
                   help="The URL of the remote cache (defaults to the first configured cache)")
    
    962
    -@click.argument('elements', nargs=-1,
    
    963
    -                type=click.Path(readable=False))
    
    961
    +@click.argument('artifacts', type=click.Path(), nargs=-1)
    
    964 962
     @click.pass_obj
    
    965
    -def artifact_pull(app, elements, deps, remote):
    
    963
    +def artifact_pull(app, artifacts, deps, remote):
    
    966 964
         """Pull a built artifact from the configured remote artifact cache.
    
    967 965
     
    
    968 966
         By default the artifact will be pulled one of the configured caches
    
    ... ... @@ -977,12 +975,28 @@ def artifact_pull(app, elements, deps, remote):
    977 975
         """
    
    978 976
     
    
    979 977
         with app.initialized(session_name="Pull"):
    
    980
    -        if not elements:
    
    978
    +        cache = app.context.artifactcache
    
    979
    +
    
    980
    +        elements, artifacts = _classify_artifacts(artifacts, cache.cas,
    
    981
    +                                                  app.project.directory)
    
    982
    +
    
    983
    +        # Guess the element if we're in a workspace
    
    984
    +        if not elements and not artifacts:
    
    981 985
                 guessed_target = app.context.guess_element()
    
    982 986
                 if guessed_target:
    
    983 987
                     elements = (guessed_target,)
    
    984 988
     
    
    985
    -        app.stream.pull(elements, selection=deps, remote=remote)
    
    989
    +        if artifacts and deps != 'none':
    
    990
    +            raise AppError("--deps may not be used with artifact refs")
    
    991
    +
    
    992
    +        if elements:
    
    993
    +            app.stream.pull(elements, selection=deps, remote=remote)
    
    994
    +        # FIXME: We can only obtain project/user config through the stream API,
    
    995
    +        # which we need to determine the remote in order for pull to pull from.
    
    996
    +        # We can't just go straight to artifactcache here. Thus Stream.Pull()
    
    997
    +        # will fail because it expects a list of element names (.bst).
    
    998
    +        if artifacts:
    
    999
    +            app.stream.pull(artifacts, selection='none', remote=remote)
    
    986 1000
     
    
    987 1001
     
    
    988 1002
     ##################################################################
    
    ... ... @@ -994,10 +1008,9 @@ def artifact_pull(app, elements, deps, remote):
    994 1008
                   help='The dependencies to push (default: none)')
    
    995 1009
     @click.option('--remote', '-r', default=None,
    
    996 1010
                   help="The URL of the remote cache (defaults to the first configured cache)")
    
    997
    -@click.argument('elements', nargs=-1,
    
    998
    -                type=click.Path(readable=False))
    
    1011
    +@click.argument('artifacts', type=click.Path(), nargs=-1)
    
    999 1012
     @click.pass_obj
    
    1000
    -def artifact_push(app, elements, deps, remote):
    
    1013
    +def artifact_push(app, artifacts, deps, remote):
    
    1001 1014
         """Push a built artifact to a remote artifact cache.
    
    1002 1015
     
    
    1003 1016
         The default destination is the highest priority configured cache. You can
    
    ... ... @@ -1014,12 +1027,28 @@ def artifact_push(app, elements, deps, remote):
    1014 1027
             all:   All dependencies
    
    1015 1028
         """
    
    1016 1029
         with app.initialized(session_name="Push"):
    
    1030
    +        cache = app.context.artifactcache
    
    1031
    +
    
    1032
    +        elements, artifacts = _classify_artifacts(artifacts, cache.cas,
    
    1033
    +                                                  app.project.directory)
    
    1034
    +
    
    1035
    +        # Guess the element if we're in a workspace
    
    1017 1036
             if not elements:
    
    1018 1037
                 guessed_target = app.context.guess_element()
    
    1019 1038
                 if guessed_target:
    
    1020 1039
                     elements = (guessed_target,)
    
    1021 1040
     
    
    1022
    -        app.stream.push(elements, selection=deps, remote=remote)
    
    1041
    +        if artifacts and deps != 'none':
    
    1042
    +            raise AppError("--deps may not be used with artifact refs")
    
    1043
    +
    
    1044
    +        if elements:
    
    1045
    +            app.stream.push(elements, selection=deps, remote=remote)
    
    1046
    +        # FIXME: We can only obtain project/user config through the stream API,
    
    1047
    +        # which we need to determine the remote in order for pull to pull from.
    
    1048
    +        # We can't just go straight to artifactcache here. Thus Stream.Pull()
    
    1049
    +        # will fail because it expects a list of element names (.bst).
    
    1050
    +        if artifacts:
    
    1051
    +            app.stream.push(artifacts, selection='none', remote=remote)
    
    1023 1052
     
    
    1024 1053
     
    
    1025 1054
     ################################################################
    



  • [Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]