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

DM-25030 make an import butler subcommand #293

Merged
merged 14 commits into from May 30, 2020
Merged

DM-25030 make an import butler subcommand #293

merged 14 commits into from May 30, 2020

Conversation

n8pease
Copy link
Contributor

@n8pease n8pease commented May 28, 2020

No description provided.

Copy link
Member

@timj timj left a comment

Choose a reason for hiding this comment

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

Looks okay.

# better than hard coding the function names into these conversion
# functions. An extension of the 'cli/resources.yaml' file (as is currently
# used in obs_base) might be a good way to do it.
if functionName == "butler_import":
Copy link
Member

Choose a reason for hiding this comment

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

One other option that may be less prone to scaling problems could be to define a dict that maps from "import" to "butler_import" and then automatically generate the inverse dict. Then in these two functions you do the equivalent of:

functionName = funcToCommand.get(functionName, functionName)

(I understand that my dict name there is non-optimal)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I thought about making some kind of data structure like that, but if I'm going to do even that much work I wanted to take a moment to figure out the best way to solve the problem. I think it might involve the plugin system, but I didn't want to spent that much time on it or add complexity, yet.


Parameters
----------
required : bool, optional
Copy link
Member

Choose a reason for hiding this comment

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

Backticks around the bool are needed for numpydoc.


Returns
-------
butler : Butler
Copy link
Member

Choose a reason for hiding this comment

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

backticks on Butler.

directory : `str`, or None
Directory containing dataset files. If `None`, all file paths must be
absolute.
export_file : `str`, optional
Copy link
Member

Choose a reason for hiding this comment

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

This doesn't look like an optional parameter in the sense that you don't need to specify it. You do need to specify it but it can be None.

filename=export_file,
transfer=transfer,
format="yaml")
return butler
Copy link
Member

Choose a reason for hiding this comment

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

I don't see anything using this return parameter. Why does it exist?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

leftover from trying to fix a unit test issue that ended up not being an issue. Not needed, will remove.

case below.
"""
with self.runner.isolated_filesystem():
f = open("output.yaml", "w")
Copy link
Member

Choose a reason for hiding this comment

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

What is the purpose of opening this file? It doesn't seem to be used anywhere.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

also leftover from addressing a unit test issue, the fix ended up becoming ExportFileCase. Will remove.

Parameters
----------
repo : `str`
URI to the location of the repo.
Copy link
Member

Choose a reason for hiding this comment

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

URI to the location of the repo or URI to a config file describing the repo and its location.

@@ -84,31 +84,33 @@ def test_loadAndExecutePluginCommand(self):
runner = click.testing.CliRunner()
with command_test_env(runner):
result = runner.invoke(butler.cli, "command-test")
self.assertEqual(result.exit_code, 0, result.output)
self.assertEqual(result.exit_code, 0, f"output: {result.output} exception: {result.exception}")
Copy link
Member

Choose a reason for hiding this comment

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

It seems like you have fixed the commands caching so I think that means you can remove the setUp above.

@n8pease n8pease force-pushed the tickets/DM-25030 branch 3 times, most recently from bfb4125 to 6884e08 Compare May 29, 2020 21:58
@n8pease n8pease merged commit 2b94c74 into master May 30, 2020
@timj timj deleted the tickets/DM-25030 branch February 16, 2024 17:18
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.

None yet

2 participants