Coder Social home page Coder Social logo

Comments (5)

frenzymadness avatar frenzymadness commented on May 30, 2024

By the way, I'm on PyConPL till Sunday so feel free to ping me and we can meet and discuss it.

from databooks.

murilo-cunha avatar murilo-cunha commented on May 30, 2024

Yes let's do that!!

Not sure why this is happening at a first glance tbh. Let's meet up and we can look into it 🤝

from databooks.

frenzymadness avatar frenzymadness commented on May 30, 2024

I think we should discuss this. For operations like meta, there is no need to look for git repository. If I run databooks meta something.ipynb without a git repository, I get:

Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "/home/lbalhar/Software/databooks/databooks/__main__.py", line 4, in <module>
    app(prog_name="databooks")
  File "/home/lbalhar/.virtualenvs/databooks/lib/python3.11/site-packages/typer/main.py", line 214, in __call__
    return get_command(self)(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/lbalhar/.virtualenvs/databooks/lib/python3.11/site-packages/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/lbalhar/.virtualenvs/databooks/lib/python3.11/site-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
         ^^^^^^^^^^^^^^^^
  File "/home/lbalhar/.virtualenvs/databooks/lib/python3.11/site-packages/click/core.py", line 1655, in invoke
    sub_ctx = cmd.make_context(cmd_name, args, parent=ctx)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/lbalhar/.virtualenvs/databooks/lib/python3.11/site-packages/click/core.py", line 920, in make_context
    self.parse_args(ctx, args)
  File "/home/lbalhar/.virtualenvs/databooks/lib/python3.11/site-packages/click/core.py", line 1378, in parse_args
    value, args = param.handle_parse_result(ctx, opts, args)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/lbalhar/.virtualenvs/databooks/lib/python3.11/site-packages/click/core.py", line 2360, in handle_parse_result
    value = self.process_value(ctx, value)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/lbalhar/.virtualenvs/databooks/lib/python3.11/site-packages/click/core.py", line 2322, in process_value
    value = self.callback(ctx, self, value)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/lbalhar/.virtualenvs/databooks/lib/python3.11/site-packages/typer/main.py", line 833, in wrapper
    return callback(**use_params)  # type: ignore
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/home/lbalhar/Software/databooks/databooks/cli.py", line 52, in _config_callback
    get_config(
  File "/home/lbalhar/Software/databooks/databooks/config.py", line 19, in get_config
    repo_dir = get_repo().working_dir
               ^^^^^^^^^^
  File "/home/lbalhar/Software/databooks/databooks/git_utils.py", line 38, in get_repo
    repo = Repo(path=repo_dir)
           ^^^^^^^^^^^^^^^^^^^
  File "/home/lbalhar/.virtualenvs/databooks/lib/python3.11/site-packages/git/repo/base.py", line 266, in __init__
    self.working_dir: Optional[PathLike] = self._working_tree_dir or self.common_dir
                                                                     ^^^^^^^^^^^^^^^
  File "/home/lbalhar/.virtualenvs/databooks/lib/python3.11/site-packages/git/repo/base.py", line 347, in common_dir
    raise InvalidGitRepositoryError()
git.exc.InvalidGitRepositoryError

And in situations where you need a git repository for example for getting a list of files with conflicts, the app should look for git repository to which the file belongs to instead of the one in CWD. Let's say I have a git repo in /foo/bar/ and a file with conflict in /foo/bar/notebooks/file.ipynb and I run the tool from /tmp - the tool should find the repo in /foo/bar.

But the main question is, why do you need a repository at all? I think it can be necessary only for the new diff command but meta, assert, fix and show commands don't need it at all.

from databooks.

murilo-cunha avatar murilo-cunha commented on May 30, 2024

That's a good point. We always look for git repos by default to look for config files (look until the repo root and if there's no pyproject.toml until then use default values) - but I agree we shouldn't see errors if we cannot find them.

why do you need a repository at all? I think it can be necessary only for the new diff command but meta, assert, fix and show commands don't need it at all.

That would be the case for meta and assert, but for fix and diff we do need the git repos - fix we actually look at the git-ls-files to get the blobs of the original files and compare them (so we're not reeeeeally fixing anything but rather going back to previous versions and comparing them). And for that we need the git repo info.

the app should look for git repository to which the file belongs to instead of the one in CWD

Completely agree. There is an implementation for finding the common parent (in case you pass different paths) and looking for the repo root there but I don't think we're using it everywhere (which we definitely should).

So summary of changes:

  1. Return default values in the CLI in case we don't find the repo (for meta and assert)
  2. All git repos should be found based on the file paths, not the current working dir

from databooks.

murilo-cunha avatar murilo-cunha commented on May 30, 2024

Done!! And thanks for the suggestion! Maybe worth double checking with you that the fixes are working?

@frenzymadness

from databooks.

Related Issues (14)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.