Skip to content

Commit

Permalink
Instruct create-target-data job to write to current working directory
Browse files Browse the repository at this point in the history
This is an experiment to see if multiple jobs writing target-data to the
github workflow's working directory can later be combined and moved to
target-data so we can submit everything in a single PR.
  • Loading branch information
bsweger committed Jan 22, 2025
1 parent dccdf28 commit 1b62b62
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 9 deletions.
20 changes: 15 additions & 5 deletions .github/workflows/run-post-submission-jobs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -83,22 +83,24 @@ jobs:
with:
version: ">=0.0.1"

# REMOVE collection_min_date, it's there for running faster tests
- name: Create target data 🎯
run: |
echo "sequence_as_of: $SEQUENCE_AS_OF"
echo "sequence_as_of: ${{ env.SEQUENCE_AS_OF }}"
uv run get_target_data.py \
--nowcast-date=${{ matrix.nowcast-date }} \
--sequence-as-of=${{ env.SEQUENCE_AS_OF }}
--sequence-as-of=${{ env.SEQUENCE_AS_OF }} \
--target-data-dir=${{ github.workspace }}
--collection_min_date=2025-01-15
working-directory: src

- name: Upload target data 📤
uses: actions/upload-artifact@v4
with:
name: target-data-${{ matrix.nowcast-date }}
path: |
time-series/**/**/*.parquet
oracle-output/**/*.parquet
${{ github.workspace }}/time-series/**/**/*.parquet
${{ github.workspace }}/oracle-output/**/*.parquet
target-data-pr:
runs-on: ubuntu-latest
Expand All @@ -110,12 +112,20 @@ jobs:
with:
pattern: target-data-*
path: ${{ github.workspace }}


- name: debug1
run: |
ls -l ${{ github.workspace }}
- name: Move target and interim data to hub directory ➡️
run: |
mv ${{ github.workspace }}/time-series ${{ github.workspace }}/target-data/
mv ${{ github.workspace }}/oracle-output ${{ github.workspace }}/target-data/
- name: debug2
run: |
ls -l target-data/
- name: Create PR for new target and interim data
uses: ./.github/actions/create-pr
with:
Expand Down
23 changes: 19 additions & 4 deletions src/get_target_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,17 @@ def set_collection_max_date(ctx, param, value):
value = value.replace(hour=23, minute=59, second=59, tzinfo=timezone.utc)
return value

def set_target_data_dir(ctx, param, value):
"""Set the target_data_dir default value to the hub's target-data directory."""
if value is None:
value = Path(__file__).parents[1] / "target-data"
elif value == ".":
value = Path.cwd()
else:
value = Path(value)

return value


@click.command()
@click.option(
Expand Down Expand Up @@ -177,10 +188,14 @@ def set_collection_max_date(ctx, param, value):
)
@click.option(
"--target-data-dir",
type=Path,
type=str,
required=False,
default=Path(__file__).parents[1] / "target-data",
help="For testing only: Path object to the directory where the target data will be saved. Default is the hub's target-data directory.",
default=None,
callback=set_target_data_dir,
help=(
"Path object to the directory where the target data will be saved. Default is the hub's target-data directory. "
"Specify '.' to save target data to the current working directory."
)
)
def main(
nowcast_date: datetime,
Expand Down Expand Up @@ -589,7 +604,7 @@ def test_target_data_integration(caplog, tmp_path):
"--nowcast-date",
nowcast_date,
"--target-data-dir",
tmp_path,
str(tmp_path),
],
color=True,
catch_exceptions=False,
Expand Down

0 comments on commit 1b62b62

Please sign in to comment.