Skip to content

Commit

Permalink
Add servicex deliver command line to submit a yaml file
Browse files Browse the repository at this point in the history
  • Loading branch information
BenGalewsky committed Dec 17, 2024
1 parent d81d666 commit 2c958ad
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 0 deletions.
7 changes: 7 additions & 0 deletions docs/command_line.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,13 @@ Common command line arguments:
If no backend is specified then the client will attempt to
use the ``default_endpoint`` value to determine who to talk to.

deliver
~~~~~~~
This command is used to submit a yaml configuration file to the serviceX backend.
It will print the paths to the resulting files.

Provide the path to the configuration file as an argument to the command.

codegens
~~~~~~~~

Expand Down
16 changes: 16 additions & 0 deletions servicex/app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@
import rich
import typer

from servicex import servicex_client
from servicex._version import __version__
from servicex.app.cli_options import backend_cli_option, config_file_option
from servicex.app.datasets import datasets_app
from servicex.app.transforms import transforms_app
from servicex.app.cache import cache_app
Expand Down Expand Up @@ -63,5 +65,19 @@ def main_info(
pass


@app.command()
def deliver(
backend: Optional[str] = backend_cli_option,
config_path: Optional[str] = config_file_option,
spec_file: str = typer.Argument(..., help="Spec file to submit to serviceX")):
"""
Deliver a file to the ServiceX cache.
"""

print(f"Delivering {spec_file} to ServiceX cache")
results = servicex_client.deliver(spec_file, servicex_name=backend, config_path=config_path)
rich.print(results)


if __name__ == "__main__":
app()
15 changes: 15 additions & 0 deletions tests/app/test_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,25 @@
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
from unittest.mock import Mock, patch


def test_app_version(script_runner):
import servicex._version
result = script_runner.run(['servicex', '--version'])
assert result.returncode == 0
assert result.stdout == f'ServiceX {servicex._version.__version__}\n'


def test_deliver(script_runner):
with patch('servicex.app.main.servicex_client') as mock_servicex_client:
mock_servicex_client.deliver = Mock(return_value={
"UprootRaw_YAML": [
"/tmp/foo.root",
"/tmp/bar.root"
]})
result = script_runner.run(['servicex', 'deliver', "foo.yaml"])
assert result.returncode == 0
result_rows = result.stdout.split('\n')
assert result_rows[0] == 'Delivering foo.yaml to ServiceX cache'
assert result_rows[1] == "{'UprootRaw_YAML': ['/tmp/foo.root', '/tmp/bar.root']}"

0 comments on commit 2c958ad

Please sign in to comment.