Skip to content

Commit

Permalink
Merge pull request #248 from aai-institute/easier-rev-parse
Browse files Browse the repository at this point in the history
Simplify revision parsing in the tutorial notebook
  • Loading branch information
nicholasjng authored Jan 8, 2024
2 parents 125d6c4 + 61921a5 commit 9c936ca
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
6 changes: 3 additions & 3 deletions docs/tutorials/demo_data_science_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -358,13 +358,13 @@ def transform_json_weather_data(filepath):
Manually, we could go into the lakeFS UI, select the training branch, and navigate to the **Commits** tab.
There, we take the parent of the previous commit, titled `Add train-test split of 2010 weather data`, and copy its revision SHA (also called `ID`).
In code, we can use a versioning helper called `rev_parse` to obtain commit SHAs for different revisions on the `training` branch.
In code, we can obtain commit SHAs for different revisions on the `training` branch by using `lakefs.Reference` objects.
"""

# %%

# parent is the parent number of a commit relative to HEAD (the latest commit, for which parent = 0).
previous_commit = list(repo.branch(TRAINING_BRANCH).log(2))[-1]
# access the data of the previous commit with a lakefs ref expression, in this case the same as in git.
previous_commit = repo.ref(f"{TRAINING_BRANCH}~").get_commit()
fixed_commit_id = previous_commit.id
print(fixed_commit_id)

Expand Down
3 changes: 1 addition & 2 deletions src/lakefs_spec/spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -313,8 +313,7 @@ def get_file(
rpath = stringify_path(rpath)
lpath = stringify_path(lpath)

lp = Path(lpath)
if precheck and lp.exists() and lp.is_file():
if precheck and Path(lpath).is_file():
local_checksum = md5_checksum(lpath, blocksize=self.blocksize)
remote_checksum = self.info(rpath).get("checksum")
if local_checksum == remote_checksum:
Expand Down

0 comments on commit 9c936ca

Please sign in to comment.