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

Custom importer Improvements #1281

Closed

Conversation

MinchinWeb
Copy link
Contributor

@MinchinWeb MinchinWeb commented Jun 27, 2021

Further to #1006

  • explicitly write the journal to disk (after importing entries), rather than assuming the plugin will do this
  • be more consistent in how data fed to the custom JSON importer is dealt with (i.e. pharse both input files and stdin into JSON)
  • first pass at a test for the custom JSON importer. The test isn't running for me locally, but also isn't displaying any error message, so I'm not sure what's going on

jrnl/plugins/exporter/dates.py Outdated Show resolved Hide resolved
@micahellison
Copy link
Member

Hey @MinchinWeb, it looks like the test isn't running because it's being excluded by the @skip_only_with_external_plugins tag. The more I think about it, the more I'm hesitant to ask for a change on this, though, since it would need to be re-written anyway after merging #1193 in, and we're very close to finishing that.

@@ -31,7 +31,8 @@ Feature: Functionality of Importer and Exporter Plugins
Given We use the config "basic_onefile.yaml"
When We run "jrnl --version"
Then the output should contain pyproject.toml version
And The output should contain "<plugin_name> : <version> from jrnl.<source>.<type>.<filename>"
And the output should contain "<plugin_name> : <version> from jrnl.<source>.<type>.<filename>"
Copy link
Member

Choose a reason for hiding this comment

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

It's good that we're fixing up the tests, so this is fine. For future test fixes/updates, though, can we focus on the /tests/bdd/features directory instead?

@skip_only_with_external_plugins
Scenario Outline: Custom JSON Import
Given we use the config "empty_folder.yaml"
When we run "jrnl --import ./features/data/simple_import.json"
Copy link
Member

Choose a reason for hiding this comment

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

No need to fix this here, but when we move this test to Pytest BDD, we should pipe this json in so it sits in the feature file (instead of having a separate file to manage).

except KeyboardInterrupt:
print(
"[Entries NOT imported into journal.]",
file=sys.stderr,
)
sys.exit(0)
data = json.loads(f)
Copy link
Member

Choose a reason for hiding this comment

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

👍

Copy link
Member

@wren wren left a comment

Choose a reason for hiding this comment

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

I added some more inline comments.

@wren wren marked this pull request as draft July 13, 2021 19:55
@MinchinWeb
Copy link
Contributor Author

it looks like the test isn't running because it's being excluded by the @skip_only_with_external_plugins tag.

Except most of the other tests in the file are similarly tagged, and they do run....

As for #1193, it looks like that was merged to develop, so I'm not sure how best to move forward on that.

Otherwise, I think all the review comments have been resolved.

@MinchinWeb MinchinWeb marked this pull request as ready for review July 14, 2021 03:38
MinchinWeb and others added 4 commits July 17, 2021 12:47
* behavior outline
* FIrst pass at allow external plugins
* remove template exporter
* Add listing of active plugins to '--version' output
* Documentation for plugins
* [Docs] add custom imports and exporters to site TOC
* [Docs] better linewrapping
* enforce positive initial linewrap
  Check column widths
  update gitignore
  throw error when linewrap too small
  simply check for large enough linewrap value
* delete unused error message
* PR feedback
  make exception more informative
  update check_linewrap signature in src and test
  make check_linewrap a free function
* delete unused function
* delete else..pass block
* newline for make format
* Include dates_exporter
* Use Base classes for importer and exporters.
* [Docs] improve documentation of custom Importers and Exporters
* [Testing] separate run with external plugin!
* basic behavior test
* prototype unittest for JSON Exporter
  test for unimplemented method
* make format
  delete unused imports
* Remove 'importer' or 'exporter' from filenames where not needed
* [Test] run different tests with or without the external plugins installed
* [Test] move test rot13 plugin into git tree
  from MinchinWeb/jrnl-rot13-exporter@0dc912a
* consolidate demo plugins to common package
* [Docs] name page for plugins
* [Docs] include the sample plug in code files directly
* style fixes
* [test] determine whether to run external plug in tests based on installed packages
* improved code documentation
* style fixes for GitHub actions
* Convert "short" and "pretty" (and "default") formaters to plugins
  further to jrnl-org#1177
* more code clean up
  tests pass locally...now for GitHub...
* [tests] dynamically determine jrnl version for plugin tests
* [GitHub Actions] direct install of testing plugins
* Remove template code
* [plugins] meta --> collector
* [Docs] create scripted entries using an custom importer
* (closer to) being able to run behave tests outside project root directory
* We already know when exporter to use
  Don't re-calculate it!
* [Tests] don't name test plugin 'testing"
  If so named, pip won't install it.
* [Test] run behave tests with test plugins outside project root
* [Test] behave tests pass locally
* [Docs] fix typo
* [GitHub Actions] run test commands from poetry's shell
* black-ify code
* [GitHub Actions] move downstream (rather than up) to run tests
* [GitHub Actions] set shell to poetry
* [GitHub Workflows] Manually activate virtual environment
* [GitHub Actions] Skip Windows & Python 3.8
  Can't seem to find Python exe?
* [GiotHub Actions] explicitly use virtual env
* [GitHub Actions] create virutal env directly
* [GitHub Actions] better activate of Windows virtual env
* [GitHub Actions] create virtual env on Mac
* [Github Actions] install wheel and upgrade pip
* [GitHub Actions] skip virtual environments altogether
* [GitHub Actions] change directory for behave test
* Remove Windows exclusions from CI as per note -- they should be working now

Co-authored-by: Suhas <sugas182@gmail.com>
Co-authored-by: Micah Jerome Ellison <micah.jerome.ellison@gmail.com>
Since we're implementing a plugin system that relies on implicit
namespacing, we should remove these files so that they don't confuse and
muddle our virtual envs (like the ones we use to run tests).

Also, they're not longer needed as of Python 3.3.

PEP 420 says:
Allowing implicit namespace packages means that the requirement to
provide an __init__.py file can be dropped completely...
Allows you to access jrnl by running `python -m jrnl`
* Move plugins tests back into normal test workflow

* change when tests run

* make tests slightly more readable in PR
Importers: handle writing the journal to disk ourselves (rather than delegating to the plugin)
Plugins: First pass at testing custom importer
@wren
Copy link
Member

wren commented Jul 17, 2021

@MinchinWeb I updated the feature-plugins branch with the updates to develop, and then resolved the conflicts from this branch (since the merge conflict was pretty big, I didn't want you to have to deal with that). Anyway, thank you for addressing the feedback!

@MinchinWeb
Copy link
Contributor Author

MinchinWeb commented Jul 17, 2021

@wren So what's left? Just to move the tests to the new pytest framework? (P.S. thanks for dealing with the merge conflict!)

…adding in appropriate parameters and no error step
@micahellison
Copy link
Member

Hey @MinchinWeb -- I just fixed the test, though it is failing now. There were a couple problems with it -- it was using the scenario outline, but had no examples, so behave iterated through the empty list and ran 0 tests from it. It also wasn't using the --file and --format keywords or checking for errors.

Also, could you modify the import test to take in new data? Currently, it imports data that's already in the journal defined by simple.yaml, so even if the import silently fails, it will still pass when it checks the contents at the end of the test:

        Then the journal should contain "My first entry."
        And the journal should contain "Life is good."

@wren
Copy link
Member

wren commented Jul 17, 2021

@MinchinWeb Yup! We just need to move the tests.

And to clarify what @micahellison is saying, the sample plugin doesn't quite work right now (you can test by installing it locally). So, fixing the test or modifying the test, it should hopefully go into pytest.

@MinchinWeb
Copy link
Contributor Author

MinchinWeb commented Jul 17, 2021

P.S. Note the the Window scenarios in the CI aren't actually running tests...

I get about a dozen failing tests locally (on Windows) and the trackbacks aren't making a lot of sense....

@wren wren marked this pull request as draft September 11, 2021 21:07
@stale
Copy link

stale bot commented Nov 16, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale Inactive issue: will be closed soon if no activity label Nov 16, 2021
@micahellison
Copy link
Member

Closing due to staleness. Feel free to re-open with new contributions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stale Inactive issue: will be closed soon if no activity
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants