Skip to content

Automation - #3

Open
dannyjacobs wants to merge 50 commits into
mainfrom
automation
Open

Automation#3
dannyjacobs wants to merge 50 commits into
mainfrom
automation

Conversation

@dannyjacobs

Copy link
Copy Markdown
Contributor

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.

Danny Jacobs and others added 8 commits April 2, 2025 10:09
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
@dannyjacobs
dannyjacobs requested a review from bhazelton April 6, 2025 23:58
@codecov

codecov Bot commented Apr 6, 2025

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 20.68966% with 23 lines in your changes missing coverage. Please review.
✅ Project coverage is 93.42%. Comparing base (357aa2f) to head (9151422).

Files with missing lines Patch % Lines
src/heratape/files.py 23.52% 13 Missing ⚠️
src/heratape/tapes.py 16.66% 10 Missing ⚠️
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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@jaguirre

jaguirre commented Apr 7, 2025

Copy link
Copy Markdown

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.
@dannyjacobs

Copy link
Copy Markdown
Contributor Author

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 bhazelton left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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.

Comment thread README.md Outdated
Comment on lines +33 to +34
Thge changer is
`/dev/sg25`

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

trails off...

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

thats telling you the changer device path. What else should it say?

Comment thread src/heratape/files.py
Comment on lines +308 to +312
# 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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

need a proper docstring, numpy style.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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

Comment thread src/heratape/files.py Outdated
# 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(), \

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This can be written instead as:

Suggested change
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.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This also applies 2 lines down

Comment thread src/heratape/files.py Outdated
Comment on lines +322 to +323
#input: a tape serial number
#output: total data volume in bytes

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

need a proper docstring, numpy style

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I also think that I'd expect to find this in tapes.py rather than files.py.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

it operates on the files table, not tapes.

Comment thread src/heratape/tape_system.py Outdated
Comment on lines +5 to +6
#input drivenum = 0 or 1
#returns: VolumeTag of tape in drive

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

need a proper docstring, numpy style

Comment thread scripts/heratape_backup.py Outdated
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:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

why bother with this if statement?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

the debug log tells you the tar command that would have been run. But doesn't actually do it.

Comment thread scripts/retry_failed_tape.py Outdated
# 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()

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
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()

Comment thread scripts/retry_failed_tape.py Outdated
Comment on lines +36 to +37
unfinished_jds = ht_sess.query(func.distinct(Files.jd)).\
where(Files.write_date == None).where(Files.tape_id == utape[0]).all()

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
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()

Comment thread scripts/retry_failed_tape.py Outdated
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??

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

there is no unsubmitted code. This is it!

Comment thread scripts/tape_scan_to_db.py Outdated
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):

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It doesn't look like this file is doing much...

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

isn't this what you want scripts to be? just a function with no code in the actual script?

@dannyjacobs

Copy link
Copy Markdown
Contributor Author

@bhazelton RE Testing
How do we test functions that use the tape hardware?

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants