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

Test1 converted project cards #13

Open
wants to merge 28 commits into
base: Test1
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
df0a02a
GitHub Action automated registry update
github-actions[bot] Sep 5, 2024
f771eae
convert project card to v1 format
yueshuaing Sep 5, 2024
cd8c44d
GitHub Action automated registry update
github-actions[bot] Sep 5, 2024
43bd881
Remove the parallel managed lane for link 276573
yueshuaing Sep 11, 2024
fd834b2
GitHub Action automated registry update
github-actions[bot] Sep 11, 2024
0cc75e7
add comments
yueshuaing Sep 11, 2024
3ac499e
GitHub Action automated registry update
github-actions[bot] Sep 11, 2024
b640ac8
add notebook used to convert project cards
yueshuaing Sep 25, 2024
3781967
GitHub Action automated registry update
github-actions[bot] Sep 25, 2024
a78f73b
ensure link attrs remain the same
yueshuaing Oct 4, 2024
43ca951
GitHub Action automated registry update
github-actions[bot] Oct 4, 2024
d0ae78f
Delete hia_46th_cleanup.yml
yueshuaing Oct 29, 2024
3cc81e4
update network wrangler branch name
yueshuaing Oct 29, 2024
9e733a8
upgrade python version
yueshuaing Oct 29, 2024
11324a6
install pytest
yueshuaing Oct 29, 2024
aaecd3c
code changes based on new network wrangler
yueshuaing Oct 29, 2024
3397cbd
remove "Old" project cards
yueshuaing Oct 30, 2024
2c4a146
GitHub Action automated registry update
github-actions[bot] Oct 30, 2024
339c42d
change str True to boolean
yueshuaing Oct 30, 2024
d4c1d5c
add transit routing changes to fix broken shapes caused by roadway de…
yueshuaing Oct 30, 2024
2569d93
trying to rename things
RachelWikenMC Dec 10, 2024
0eab74f
GitHub Action automated registry update
github-actions[bot] Dec 10, 2024
b31c1a8
renaming again
RachelWikenMC Dec 10, 2024
1db0202
GitHub Action automated registry update
github-actions[bot] Dec 10, 2024
2eeed2f
add v5 base transit network correction
yueshuaing Dec 16, 2024
914f4ea
GitHub Action automated registry update
github-actions[bot] Dec 16, 2024
b245d5f
converted fall 2024 cards
RachelWikenMC Jan 10, 2025
f6901ef
GitHub Action automated registry update
github-actions[bot] Jan 10, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions .github/workflows/update-registry.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,13 @@ jobs:
- name: setup python
uses: actions/setup-python@v2
with:
python-version: '3.7'
python-version: '3.10'

- name: execute py script
run: |
python -m pip install --upgrade pip
pip install --user -e git+https://github.com/wsp-sag/network_wrangler.git@master#egg=network_wrangler
pip install --user -e git+https://github.com/wsp-sag/network_wrangler.git@main#egg=network_wrangler
pip install pytest
python update_registry.py

- name: commit files
Expand Down
31 changes: 16 additions & 15 deletions methods_add_cards.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
from numpy import True_
import pandas as pd
from typing import Tuple
from network_wrangler import ProjectCard
from projectcard import ProjectCard
from projectcard import write_card


def add_cards_to_registry(
Expand Down Expand Up @@ -30,8 +31,8 @@ def add_cards_to_registry(
for card, filename in card_file_list:
if card.project not in input_df["project_added"].values:
for change_index, change_dict in enumerate(card.changes):
if change_dict.get("category", "Missing") == "Add New Roadway":
if "nodes" in change_dict:
if "roadway_addition" in change_dict:
if "nodes" in change_dict["roadway_addition"]:
node_df, node_update, card = _update_registry(
"nodes",
out_df,
Expand All @@ -52,10 +53,10 @@ def add_cards_to_registry(
)

if node_df is not None:
out_df = out_df.append(node_df, ignore_index=True)
out_df = pd.concat([out_df, node_df], ignore_index=True)

out_df = (
out_df.append(link_df, ignore_index=True)
pd.concat([out_df, link_df], ignore_index=True)
.drop_duplicates()
.reset_index(drop=True)
)
Expand All @@ -66,7 +67,7 @@ def add_cards_to_registry(
card.__dict__.pop("file")
if "valid" in card.__dict__:
card.__dict__.pop("valid")
card.write(filename=filename)
write_card(filename=filename)

return out_df

Expand Down Expand Up @@ -238,7 +239,7 @@ def _update_registry(

subject_df = input_df[input_df["type"] == subject_word]

for subject_index, subject in enumerate(card.changes[change_index][nodes_or_links]):
for subject_index, subject in enumerate(card.changes[change_index]["roadway_addition"][nodes_or_links]):
new_id = subject[subject_id_word]

_is_id_in_allowable_range(subject_word, card.project, new_id, range_in_use)
Expand All @@ -251,7 +252,7 @@ def _update_registry(
"project_added": [card.project],
}
)
subject_df = subject_df.append(updates_df)
subject_df = pd.concat([subject_df, updates_df])
else:
number = _find_available_id(
subject_word,
Expand All @@ -260,23 +261,23 @@ def _update_registry(
range_in_use,
subject_df,
)
card.changes[change_index][nodes_or_links][subject_index][
card.changes[change_index]["roadway_addition"][nodes_or_links][subject_index][
subject_id_word
] = number
if nodes_or_links == "nodes":
for i in range(0, len(card.changes[change_index]["links"])):
if card.changes[change_index]["links"][i]["A"] == new_id:
card.changes[change_index]["links"][i]["A"] = number
if card.changes[change_index]["links"][i]["B"] == new_id:
card.changes[change_index]["links"][i]["B"] = number
for i in range(0, len(card.changes[change_index]["roadway_addition"]["links"])):
if card.changes[change_index]["roadway_addition"]["links"][i]["A"] == new_id:
card.changes[change_index]["roadway_addition"]["links"][i]["A"] = number
if card.changes[change_index]["roadway_addition"]["links"][i]["B"] == new_id:
card.changes[change_index]["roadway_addition"]["links"][i]["B"] = number
updates_df = pd.DataFrame(
{
"type": subject_word,
"id": [number],
"project_added": [card.project],
}
)
subject_df = subject_df.append(updates_df)
subject_df = pd.concat([subject_df, updates_df])
write_updated_card = True

return subject_df, write_updated_card, card
4 changes: 2 additions & 2 deletions methods_io.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import os
from network_wrangler import ProjectCard
from projectcard import read_card

CARD_DIR = os.path.join(".", "projects")

Expand All @@ -22,7 +22,7 @@ def read_project_cards(card_dir: str = CARD_DIR) -> list:
name, extension = os.path.splitext(filename)
if extension in [".yml", ".yaml"]:
card_file = os.path.join(dirpath, filename)
card = ProjectCard.read(card_file, validate=False)
card = read_card(card_file, validate=False)
card_file_list.append((card, card_file))

return card_file_list
107 changes: 107 additions & 0 deletions notebooks/.ipynb_checkpoints/convert_project_card-checkpoint.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"This script is used to convert project cards to new format (v1)"
]
},
{
"cell_type": "code",
"execution_count": 13,
"metadata": {},
"outputs": [],
"source": [
"from pathlib import Path\n",
"from projectcard.update import update_schema_for_card_file"
]
},
{
"cell_type": "code",
"execution_count": 20,
"metadata": {},
"outputs": [],
"source": [
"# project card directory where old project cards are saved\n",
"input_pc_dir = Path(r\"C:\\NW2\\projectcardsfix\\NoBuild_TPP2023\")\n",
"\n",
"# project card directory where new project cards should be saved\n",
"output_pc_dir = Path(r\"C:\\NW2\\projectcardsfix\\NoBuild_TPP2023_v1\")\n"
]
},
{
"cell_type": "code",
"execution_count": 21,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"[WindowsPath('C:/NW2/projectcardsfix/NoBuild_TPP2023/NB_2025_494_S1_lane_add_edits.yml')]"
]
},
"execution_count": 21,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# save old project cards to a list\n",
"card_files = list(Path(input_pc_dir).rglob(\"*.*[yY]*[mM][lL]\"))\n",
"card_files"
]
},
{
"cell_type": "code",
"execution_count": 22,
"metadata": {},
"outputs": [],
"source": [
"# convert old project cards in the list to new format\n",
"for p in card_files:\n",
" update_schema_for_card_file(p, output_pc_dir)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.10"
},
"vscode": {
"interpreter": {
"hash": "07e586ca5a03bbc8bef8bfbd2ac9f2aadb8cef32dbebc83b2e3513fa036ee0ca"
}
}
},
"nbformat": 4,
"nbformat_minor": 4
}
107 changes: 107 additions & 0 deletions notebooks/convert_project_card.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"This script is used to convert project cards to new format (v1)"
]
},
{
"cell_type": "code",
"execution_count": 13,
"metadata": {},
"outputs": [],
"source": [
"from pathlib import Path\n",
"from projectcard.update import update_schema_for_card_file"
]
},
{
"cell_type": "code",
"execution_count": 20,
"metadata": {},
"outputs": [],
"source": [
"# project card directory where old project cards are saved\n",
"input_pc_dir = Path(r\"C:\\NW2\\projectcardsfix\\NoBuild_TPP2023\")\n",
"\n",
"# project card directory where new project cards should be saved\n",
"output_pc_dir = Path(r\"C:\\NW2\\projectcardsfix\\NoBuild_TPP2023_v1\")\n"
]
},
{
"cell_type": "code",
"execution_count": 21,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"[WindowsPath('C:/NW2/projectcardsfix/NoBuild_TPP2023/NB_2025_494_S1_lane_add_edits.yml')]"
]
},
"execution_count": 21,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# save old project cards to a list\n",
"card_files = list(Path(input_pc_dir).rglob(\"*.*[yY]*[mM][lL]\"))\n",
"card_files"
]
},
{
"cell_type": "code",
"execution_count": 22,
"metadata": {},
"outputs": [],
"source": [
"# convert old project cards in the list to new format\n",
"for p in card_files:\n",
" update_schema_for_card_file(p, output_pc_dir)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.10"
},
"vscode": {
"interpreter": {
"hash": "07e586ca5a03bbc8bef8bfbd2ac9f2aadb8cef32dbebc83b2e3513fa036ee0ca"
}
}
},
"nbformat": 4,
"nbformat_minor": 4
}
Loading