Automation - #3
Conversation
enter the commit message for your changes. Lines starting # with '#' will be ignored, and an empty message aborts the commit. # # On branch automation # Changes to be committed: # new file: ../src/heratape/tape_system.py # # Untracked files: # ../heratape.yml
adding help draft notes to readme
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3 +/- ##
===========================================
- Coverage 100.00% 93.42% -6.58%
===========================================
Files 5 5
Lines 336 365 +29
Branches 74 78 +4
===========================================
+ Hits 336 341 +5
- Misses 0 24 +24 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
If you really want other people to be able to run this, adding to the README documentation or adding another bit of docs that explain in English what the workflow is - what scripts, in what order, need to be run for both normal operation and fixing problems - will be huge. Also, for my old brain, it's really helpful to know the order of doing things for reading all this OOP code which is never sequential / chronological. (Just wait, your brain will slow down too.) |
Roughing in more about how it all works.
|
Judging by how many dozens of hours of work it took to get to this point, this brain is already well into senescence. Have added more detail. Please ask obvious questions so I don't have to write a bunch of detail you don't care about. |
bhazelton
left a comment
There was a problem hiding this comment.
High-level comment: Putting console scripts in a folder at the top-level called "scripts" is not the recommended way to set up console scripts. The right way to do this is to write functions in .py files in the package folder (src/heratape) and then set up entry points in the pyproject.toml. See here: https://setuptools.pypa.io/en/latest/userguide/entry_point.html
That puts the code in a place that can actually be tested.
I'm happy to help with this if you want.
Second high-level comment: we need unit tests.
Third high-level comment: please install pre-commit and let it reformat your code to match the style. That will make it easier for me to read.
| Thge changer is | ||
| `/dev/sg25` |
There was a problem hiding this comment.
thats telling you the changer device path. What else should it say?
| # list the names of files with no write date | ||
| # set tape_id =None to list all, or to a tape serial number to list those | ||
| # return a list of files that weren't signed off with a write date. | ||
| # this can happen if the write was interrupted before the db could be informed of success | ||
| # writes can take hours, so this unhappy situation is likely |
There was a problem hiding this comment.
need a proper docstring, numpy style.
There was a problem hiding this comment.
I think the comment above is actually wrong in addition to not being nicely formatted. It says this returns a list. It looks to me like it returns a tuple of lists
| # writes can take hours, so this unhappy situation is likely | ||
| with HTSessionWrapper(testing=testing) as ht_sess: | ||
| if tape_id is None: | ||
| return ht_sess.query(func.distinct(Files.jd)).where(Files.write_date == None).all(), \ |
There was a problem hiding this comment.
This can be written instead as:
| return ht_sess.query(func.distinct(Files.jd)).where(Files.write_date == None).all(), \ | |
| return ht_sess.query(Files.jd).distinct().where(Files.write_date == None).all(), \ |
which I find slightly easier to read.
There was a problem hiding this comment.
This also applies 2 lines down
| #input: a tape serial number | ||
| #output: total data volume in bytes |
There was a problem hiding this comment.
need a proper docstring, numpy style
There was a problem hiding this comment.
I also think that I'd expect to find this in tapes.py rather than files.py.
There was a problem hiding this comment.
it operates on the files table, not tapes.
| #input drivenum = 0 or 1 | ||
| #returns: VolumeTag of tape in drive |
There was a problem hiding this comment.
need a proper docstring, numpy style
| else: | ||
| logger.info(" TESTING MODE: skipping real tar to tape") | ||
| logger.debug(f' the tar command: time tar -cf /dev/nst{mydrive} {len(files)} not printed') | ||
| if True: |
There was a problem hiding this comment.
why bother with this if statement?
There was a problem hiding this comment.
the debug log tells you the tar command that would have been run. But doesn't actually do it.
| # first list all the tapes in the DB with incomplete writes. Hopefully FEW | ||
| tape_jds = {} | ||
| with HTSessionWrapper(testing=TESTING) as ht_sess: | ||
| unfinished_tapes = ht_sess.query(func.distinct(Files.tape_id)).where(Files.write_date == None).all() |
There was a problem hiding this comment.
| unfinished_tapes = ht_sess.query(func.distinct(Files.tape_id)).where(Files.write_date == None).all() | |
| unfinished_tapes = ht_sess.query(Files.tape_id).distinct().where(Files.write_date == None).all() |
| unfinished_jds = ht_sess.query(func.distinct(Files.jd)).\ | ||
| where(Files.write_date == None).where(Files.tape_id == utape[0]).all() |
There was a problem hiding this comment.
| unfinished_jds = ht_sess.query(func.distinct(Files.jd)).\ | |
| where(Files.write_date == None).where(Files.tape_id == utape[0]).all() | |
| unfinished_jds = ht_sess.query(Files.jd).distinct().where( | |
| Files.write_date == None).where(Files.tape_id == utape[0] | |
| ).all() |
| for utape in unfinished_tapes: | ||
| unfinished_jds = ht_sess.query(func.distinct(Files.jd)).\ | ||
| where(Files.write_date == None).where(Files.tape_id == utape[0]).all() | ||
| unfinished_jds = [ujd[0] for ujd in unfinished_jds] #why do I get a list of length 1 tuples?? |
There was a problem hiding this comment.
I'm not sure. It'd be easier to figure out if there was a test. I can try to write one, but if you have some test code lying around please add it!
There was a problem hiding this comment.
there is no unsubmitted code. This is it!
| from heratape.tapes import list_tapes_in_db, add_new_tapes_to_db | ||
|
|
||
| update_tapes(testing=TESTING) | ||
| #def add_new_tapes_to_db(tapes,testing=TESTING): |
There was a problem hiding this comment.
It doesn't look like this file is doing much...
There was a problem hiding this comment.
isn't this what you want scripts to be? just a function with no code in the actual script?
|
@bhazelton RE Testing |
…ording to their position in the cassette at selection time
for more information, see https://pre-commit.ci
I think I have a working system. Could use some review to make sure its readable and sane. @bhazelton and maybe @plaplant
Next step is testing in screen mode. Once we get through a couple tapes we'll move to a deaemon.