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

New location for scripts #370

Merged
merged 20 commits into from Jul 30, 2018
Merged

New location for scripts #370

merged 20 commits into from Jul 30, 2018

Conversation

felixdivo
Copy link
Collaborator

This PR moved the scripts to a new location. For that, I had to change how pytest is configured to still include the scripts in the coverage data.

Preparation for Lauszus/python_can_viewer#2.

@codecov
Copy link

codecov bot commented Jul 22, 2018

Codecov Report

Merging #370 into develop will increase coverage by 0.52%.
The diff coverage is 21.73%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop     #370      +/-   ##
===========================================
+ Coverage    58.32%   58.85%   +0.52%     
===========================================
  Files           54       54              
  Lines         4250     4214      -36     
===========================================
+ Hits          2479     2480       +1     
+ Misses        1771     1734      -37
Impacted Files Coverage Δ
can/scripts/player.py 0% <0%> (ø)
can/scripts/logger.py 0% <0%> (ø)
can/__init__.py 100% <100%> (ø) ⬆️
can/scripts/__init__.py 100% <100%> (ø)
can/CAN.py
can/util.py 76.4% <0%> (+3.77%) ⬆️
can/interfaces/socketcan/socketcan.py 67.88% <0%> (+4.06%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 66ce4aa...4624791. Read the comment docs.

@felixdivo
Copy link
Collaborator Author

Done.

@christiansandberg
Copy link
Collaborator

The scrips were like that before but were moved to modules instead since it is easier to handle multiple Python installations by starting them using python -m can.logger for example like the documentation that you haven’t updated shows.

@felixdivo
Copy link
Collaborator Author

What exactly do you mean by different Python installations? Like Python 2.7 and 3 along each other? That shouldn't be a problem since our scripts works on both versions; it shouldn't matter which interpreter it is running in. We could also call it scripts/can_logger.py to aide confusion with similar scripts.

@christiansandberg
Copy link
Collaborator

Scripts are also quite hard to use on windows since it does not use the shebang line. You have to rely on the .py filetype association. Usually you must specify the absolute path to the interpreter and the script to execute the intended script with the interpreter it was installed for.

@christiansandberg
Copy link
Collaborator

See #165. In general I don’t see a problem with the current way of exposing applications using modules. It’s more consistent on all platforms.

@felixdivo
Copy link
Collaborator Author

Hm, I see. Why is Windows so complicated ...

Well, we could actually do both, right? I mean, we leave it in the scripts folder so they stay separate for a clean structure. But we could import them from the can.__init__.py to make them accessible as modules as well. I think that might work.

@christiansandberg
Copy link
Collaborator

How do you import scripts? Wouldn’t it be easier the other way around? We can put the CLI applications in a sub package like can.bin or something, and maybe have scripts that import those if you feel like it is easier for you.

@hardbyte
Copy link
Owner

I'd like to continue to support calling via can namespaced executable modules (e.g. python -m can.logger) but we could also install scripts.

p.s I like the setup.cfg changes for the pytest args etc

@hardbyte hardbyte requested review from christiansandberg and removed request for hardbyte July 24, 2018 09:56
@felixdivo
Copy link
Collaborator Author

Wouldn’t it be easier the other way around?

I guess it's quite simple either way around. The point I want to make is that these scripts are something different from the core library and thus should sit somewhere else. I will do it like you proposed, although can.scripts would be more appropriate since we don't have compiled packages in Python.

@felixdivo
Copy link
Collaborator Author

@hardbyte @christiansandberg Is this okay?

@christiansandberg
Copy link
Collaborator

I think the modules should keep being exposed as before (e.g. can.logger) as it is shorter to type and easier to remember. The script part doesn’t add any value to the user. It’s just good for internal structure.

@felixdivo
Copy link
Collaborator Author

We can put the CLI applications in a sub package like can.bin or something

Earlier this week, you did seem to not have a problem with that ...

It’s just good for internal structure.

And that's some thing very important in my point of view. Since I personally find it very confusing to have can/logger.py as well as can/io/logger.py, and stuff like that. It's not clear what these do on the first glance, and with the first one moving to can/scripts/logger.py it would be. Yes, its easier to remember if there are two of them and you are a user, but is is confusing when looking at the source and hard to extend if with further scripts. Do you want to clutter the can.* with all of them?

@christiansandberg
Copy link
Collaborator

Sorry, I was a bit unclear. What I mean is that we can remove can/logger.py but in can/init.py we can do ‘from .scripts import logger’. That way the users can still use the shorter python -m can.logger command while we have it separated internally.

@christiansandberg
Copy link
Collaborator

I know we’ve discussed this before. I think omitting most interfaces from coverage would be fine since there is little we can unit test. SocketCAN is the only we can execute on Travis. The Kvaser test tries to mock the DLL but there is very little confidence that it will work in a real environment and spending time on a test that doesn’t provide value is mostly a waste of time.

@hardbyte hardbyte merged commit d9d3fa5 into develop Jul 30, 2018
@hardbyte hardbyte deleted the new-location-for-scripts branch July 30, 2018 00:03
@felixdivo
Copy link
Collaborator Author

Well, you are right: The interfaces we can test best are virtual and socketcan. But #290 adds some serial can tests. In general, excluding interfaces might lead some to ignore that that is a major point of failure of the library, right?

image

@christiansandberg
Copy link
Collaborator

Yes it certainly is a major point of failure which is why this library is quite harder to test than other libraries. We have to rely on manual testing unfortunately and we should be able to accept new interface implementations without automatic tests.

@felixdivo
Copy link
Collaborator Author

Well, we can (and probably have to) still do that.

@christiansandberg
Copy link
Collaborator

As long as we accept merging a failed coverage CI pull request due to the lower coverage. IMO it would be best if the CI pass and fail criteria matches what we would accept and deny in a pull request.

@felixdivo
Copy link
Collaborator Author

felixdivo commented Jul 30, 2018

Well, in general that won't work, since we do not or rather probably cannot check for sufficient documentation an alike. But if you insist, go ahead and change it.

Maybe here: #374

@@ -74,6 +79,7 @@
# Code
version=version,
packages=find_packages(exclude=["test", "test.*"]),
scripts=list(filter(isfile, (join("scripts/", f) for f in listdir("scripts/")))),
Copy link
Collaborator

Choose a reason for hiding this comment

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

What is this used for?

@Lauszus
Copy link
Collaborator

Lauszus commented Aug 11, 2018

Calling: python -m can.logger does not seem to work on the develop branch? I have to use the full path: python -m can.scripts.logger.

@felixdivo
Copy link
Collaborator Author

Hey Kristian,

I am currently short of time, but created #392 so it won't be forgotten.

Felix D.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants