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

Fix/session id with env #271

Merged
merged 11 commits into from
Dec 17, 2024
2 changes: 1 addition & 1 deletion .github/workflows/tester.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pytest pandas tqdm
pip install pytest pandas tqdm IPython
pip install -e .
pip install -r requirements.txt
- name: Running Tests
Expand Down
4 changes: 0 additions & 4 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@ gspread==5.10.0
gspread_dataframe
numpy
requests
pylint==2.8.3
pytest==6.0.2
pytest-cov==2.11.1
pytest-xdist==2.1.0
pyyaml
rouge-score
torch
Expand Down
14 changes: 11 additions & 3 deletions src/dfcx_scrapi/core/environments.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,17 @@ def __init__(
creds=creds,
)

if agent_id:
self.agent_id = agent_id

self.agent_id = agent_id
self._versions = versions.Versions(creds=self.creds)
self._flows = flows.Flows(creds=self.creds)
self._environments_map = None

@property
def environments_map(self) -> Dict[str, str]:
"""Property for the environments map."""
if self._environments_map is None:
self._environments_map = self.get_environments_map(self.agent_id)
return self._environments_map

@staticmethod
def _get_flow_version_id(
Expand Down Expand Up @@ -125,6 +131,8 @@ def get_environments_map(
for environment in self.list_environments(agent_id)
}

self._environments_map = environments_dict

return environments_dict

@scrapi_base.api_call_counter_decorator
Expand Down
7 changes: 5 additions & 2 deletions src/dfcx_scrapi/core/scrapi_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,9 @@ def _set_region(resource_id: str):
instantiating other library client objects, or None
if the location is "global"
"""
if not resource_id:
raise ValueError("resource_id must not be None.")

try:
location = resource_id.split("/")[3]
except IndexError as err:
Expand Down Expand Up @@ -334,8 +337,8 @@ def _parse_resource_path(
"format": "`projects/<Project ID>/locations/<Location ID>/securitySettings/<Security Setting ID>`", # noqa: E501
},
"session": {
"matcher": fr"{matcher_root}/agents/(?P<agent>{standard_id_match})/sessions/(?P<session>{session_id_match})$", # noqa: E501
"format": "`projects/<Project ID>/locations/<Location ID>/agents/<Agent ID>/sessions/<Session ID>`", # noqa: E501
"matcher": fr"{matcher_root}/agents/(?P<agent>{standard_id_match})(?:/environments/(?P<environment>{standard_id_match}))?/sessions/(?P<session>{session_id_match})$", # noqa: E501
"format": "`projects/<Project ID>/locations/<Location ID>/agents/<Agent ID>/sessions/<Session ID>` or `projects/<Project ID>/locations/<Location ID>/agents/<Agent ID>/environments/<Environment ID>/sessions/<Session ID>`", # noqa: E501
},
"session_entity_type": {
"matcher": fr"{matcher_root}/agents/(?P<agent>{standard_id_match})/sessions/(?P<session>{session_id_match})/entityTypes/(?P<entity>{entity_id_match})$", # noqa: E501
Expand Down
Loading
Loading