Uploaded image for project: 'Data Management'
  1. Data Management
  2. DM-28257

Allow Butler to take a PosixPath object as config

    XMLWordPrintable

    Details

    • Story Points:
      2
    • Epic Link:
    • Team:
      Data Release Production
    • Urgent?:
      No

      Description

      Currently passing a pathlib.Path results in an error. Change config.py such that a path can be passed in this way.

      Suggestions from Tim Jenness:

      add it here:
      https://github.com/lsst/daf_butler/blob/master/python/lsst/daf/butler/core/config.py#L213
      and here:
      https://github.com/lsst/daf_butler/blob/master/python/lsst/daf/butler/core/_butlerUri/_butlerUri.py#L133

      with additional note that "although a path.PathLib should probably have its own else branch in ButlerURI because we know it’s a local file by definition"

        Attachments

          Activity

          Hide
          tmorton Tim Morton [X] (Inactive) added a comment -

          I'm not sure I understand your suggestion about making a separate else block (probably because I don't know what is happening inside the isinstance(other, str) block, but this just does the simplest thing of casting to string if it's a Path. Let me know if you'd like me to change it.

          Show
          tmorton Tim Morton [X] (Inactive) added a comment - I'm not sure I understand your suggestion about making a separate else block (probably because I don't know what is happening inside the isinstance(other, str) block, but this just does the simplest thing of casting to string if it's a Path. Let me know if you'd like me to change it.
          Hide
          tjenness Tim Jenness added a comment -

          I've made one comment on the PR in that I'd prefer it if Config itself didn't force the Path to a str but let ButlerURI deal with it.

          Don't worry about my comment about having a separate else. I was trying to say that for a general str argument we don't know if it's a local file or a http URI or whatever. For a Path we know for a fact it must be a local file so an else block could have dealt with it without having to check for the presence of file:// since by definition it can't have any URI scheme. Forcing it to str and relying on the old logic is fine.

          Show
          tjenness Tim Jenness added a comment - I've made one comment on the PR in that I'd prefer it if Config itself didn't force the Path to a str but let ButlerURI deal with it. Don't worry about my comment about having a separate else. I was trying to say that for a general str argument we don't know if it's a local file or a http URI or whatever. For a Path we know for a fact it must be a local file so an else block could have dealt with it without having to check for the presence of file:// since by definition it can't have any URI scheme. Forcing it to str and relying on the old logic is fine.
          Hide
          tmorton Tim Morton [X] (Inactive) added a comment -

          Why would a local `scons` pass all the pytests but the PR CI fail on GH? GH seems to have failed a flake8 test, but nothing errored locally on lsst-devl.

          Show
          tmorton Tim Morton [X] (Inactive) added a comment - Why would a local `scons` pass all the pytests but the PR CI fail on GH? GH seems to have failed a flake8 test, but nothing errored locally on lsst-devl.
          Hide
          tjenness Tim Jenness added a comment -

          It shows it working now so I imagine you fixed the problem.

          Show
          tjenness Tim Jenness added a comment - It shows it working now so I imagine you fixed the problem.
          Hide
          tmorton Tim Morton [X] (Inactive) added a comment -

          I fixed the above with the latest commit, but still seems strange that flake8 should fail on GH but not locally when running scons.

          Show
          tmorton Tim Morton [X] (Inactive) added a comment - I fixed the above with the latest commit, but still seems strange that flake8 should fail on GH but not locally when running scons .

            People

            Assignee:
            tmorton Tim Morton [X] (Inactive)
            Reporter:
            tmorton Tim Morton [X] (Inactive)
            Reviewers:
            Tim Jenness
            Watchers:
            Russell Owen, Tim Jenness, Tim Morton [X] (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:

                Jenkins

                No builds found.