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

migrate code from googleapis/python-talent #8499

Merged
merged 62 commits into from
Nov 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
1654c75
Talent v4beta1 samples [Restoring deleted branch samples] [(#3273)](h…
munkhuushmgl May 21, 2020
9623935
chore(deps): update dependency google.cloud.talent to v0.6.1 [(#3851)…
renovate-bot May 21, 2020
dba46e3
[jobs] testing: use multiple projects [(#4068)](https://github.com/Go…
Jun 12, 2020
dc0b61c
cleanup(jobs): remove unnecessary code [(#4257)](https://github.com/G…
Jul 8, 2020
df31d90
samples: Automl table batch test [(#4267)](https://github.com/GoogleC…
munkhuushmgl Jul 9, 2020
3332087
chore(deps): update dependency pytest to v5.4.3 [(#4279)](https://git…
renovate-bot Jul 12, 2020
e8b43ee
Update dependency pytest to v6 [(#4390)](https://github.com/GoogleClo…
renovate-bot Aug 1, 2020
ffe4a88
chore: update templates
busunkim96 Sep 24, 2020
5df7915
test: fix sample tests
busunkim96 Sep 24, 2020
7d3ab01
test: fix samples
busunkim96 Sep 24, 2020
a20ccd8
sample: fix parent path
busunkim96 Sep 24, 2020
3b5afee
feat: add v4 (#29)
busunkim96 Sep 28, 2020
62d5fcc
chore(deps): update dependency google.cloud.talent to v1 (#34)
renovate-bot Oct 2, 2020
a6bdca4
chore(deps): update dependency google.cloud.talent to v2 (#39)
renovate-bot Oct 2, 2020
662e92c
chore: update templates (#58)
yoshi-automation Dec 24, 2020
aef3b92
chore(deps): update dependency google.cloud.talent to v2.1.0 (#69)
renovate-bot Mar 5, 2021
d835d0c
fix: fix retry deadlines (#73)
yoshi-automation Mar 30, 2021
f15df5f
chore: migrate to owl bot (#87)
parthea May 10, 2021
e2fce3a
chore: new owl bot post processor docker image (#104)
gcf-owl-bot[bot] May 22, 2021
bc8ad2b
chore(deps): update dependency pytest to v6.2.4 (#93)
renovate-bot Jun 16, 2021
1b72402
feat: add Samples section to CONTRIBUTING.rst (#134)
gcf-owl-bot[bot] Jul 22, 2021
9d74ba9
chore: 'requirements.txt' is not a script (#131)
tseaver Jul 28, 2021
8669806
chore(deps): update dependency google.cloud.talent to v2.2.0 (#117)
renovate-bot Jul 28, 2021
2604be5
chore(deps): update dependency google.cloud.talent to v2.2.1 (#141)
renovate-bot Jul 29, 2021
fa03a8a
chore(deps): update dependency google.cloud.talent to v2.3.0 (#144)
renovate-bot Aug 10, 2021
d84d336
chore: fix INSTALL_LIBRARY_FROM_SOURCE in noxfile.py (#145)
gcf-owl-bot[bot] Aug 11, 2021
a4fa582
chore: drop mention of Python 2.7 from templates (#147)
gcf-owl-bot[bot] Aug 13, 2021
fd3fa1e
chore: blacken samples noxfile template (#160)
gcf-owl-bot[bot] Sep 17, 2021
8a5c941
chore: fail samples nox session if python version is missing (#165)
gcf-owl-bot[bot] Sep 30, 2021
5ffc898
chore(python): Add kokoro configs for python 3.10 samples testing (#170)
gcf-owl-bot[bot] Oct 8, 2021
9088d2e
chore(deps): update dependency pytest to v6.2.5 (#156)
renovate-bot Oct 25, 2021
72dbf67
chore(deps): update dependency google.cloud.talent to v2.4.0 (#178)
renovate-bot Nov 10, 2021
e1560d3
chore(python): run blacken session for all directories with a noxfile…
gcf-owl-bot[bot] Nov 11, 2021
a4df0b1
chore(samples): Add check for tests in directory (#189)
gcf-owl-bot[bot] Jan 11, 2022
01c721c
chore(python): Noxfile recognizes that tests can live in a folder (#194)
gcf-owl-bot[bot] Jan 19, 2022
4a0d0b1
chore(deps): update dependency pytest to v7 (#202)
renovate-bot Feb 9, 2022
d85a3b7
chore(deps): update all dependencies (#204)
renovate-bot Feb 26, 2022
0b56b84
chore: Adding support for pytest-xdist and pytest-parallel (#214)
gcf-owl-bot[bot] Mar 4, 2022
355f5b5
chore(deps): update dependency google.cloud.talent to v2.5.1 (#217)
renovate-bot Mar 8, 2022
495d369
chore(deps): update dependency pytest to v7.1.0 (#220)
renovate-bot Mar 13, 2022
8528541
chore(deps): update dependency pytest to v7.1.1 (#222)
renovate-bot Mar 23, 2022
29ef2b6
chore(python): use black==22.3.0 (#229)
gcf-owl-bot[bot] Mar 29, 2022
ba1dca0
chore(deps): update dependency google.cloud.talent to v2.5.2 (#232)
renovate-bot Apr 1, 2022
ebca065
chore(python): add nox session to sort python imports (#240)
gcf-owl-bot[bot] Apr 21, 2022
6000b9a
chore(deps): update dependency pytest to v7.1.2 (#243)
renovate-bot Apr 25, 2022
e077e05
fix: require python 3.7+ (#264)
gcf-owl-bot[bot] Jul 9, 2022
9c1cebd
chore(deps): update all dependencies (#255)
renovate-bot Jul 19, 2022
eaf5a33
chore(deps): update all dependencies (#270)
renovate-bot Aug 2, 2022
0e54475
chore(deps): update dependency google-cloud-talent to v2.7.1 (#277)
renovate-bot Aug 19, 2022
b0e0bc8
chore(deps): update dependency pytest to v7.1.3 (#288)
renovate-bot Sep 6, 2022
50eb826
chore: detect samples tests in nested directories (#292)
gcf-owl-bot[bot] Sep 13, 2022
8bbb862
chore(deps): update dependency google-cloud-talent to v2.7.2 (#296)
renovate-bot Oct 4, 2022
e9c3dd8
chore(deps): update dependency google-cloud-talent to v2.7.3 (#299)
renovate-bot Oct 18, 2022
60882d3
chore(deps): update dependency pytest to v7.2.0 (#300)
renovate-bot Oct 26, 2022
08bf939
Merge remote-tracking branch 'migration/main' into python-talent-migr…
Nov 11, 2022
198cc16
Added fields to codeowners and blunderbuss
Nov 14, 2022
2324832
Merge branch 'main' into python-talent-migration
xtineskim Nov 14, 2022
86d51ec
Remove noxfile
Nov 14, 2022
5ca757e
Merge branch 'python-talent-migration' of https://github.com/GoogleCl…
Nov 14, 2022
3a8078c
Merge branch 'main' into python-talent-migration
xtineskim Nov 14, 2022
36d64f9
Blunderbuss edit
Nov 14, 2022
20c08b1
Merge branch 'python-talent-migration' of https://github.com/GoogleCl…
Nov 14, 2022
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
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -68,5 +68,6 @@
/storagetransfer/**/* @GoogleCloudPlatform/cloud-storage-dpes @GoogleCloudPlatform/python-samples-reviewers
/trace/**/* @ymotongpoo @GoogleCloudPlatform/python-samples-reviewers
/translate/**/* @nicain @GoogleCloudPlatform/python-samples-reviewers
/talent/**/* @GoogleCloudPlatform/python-samples-reviewers
/workflows/**/* @GoogleCloudPlatform/python-samples-reviewers
/kms/**/** @GoogleCloudPlatform/dee-infra @GoogleCloudPlatform/python-samples-reviewers
5 changes: 4 additions & 1 deletion .github/blunderbuss.yml
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,10 @@ assign_prs_by:
- 'api: iot'
to:
- GoogleCloudPlatform/api-iot

- labels:
- 'api: talent'
to:
- GoogleCloudPlatform/python-samples-reviewers

assign_issues:
- GoogleCloudPlatform/python-samples-owners
Expand Down
6 changes: 6 additions & 0 deletions talent/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
To run the sample, you need to enable the API at: https://console.cloud.google.com/apis/library/jobs.googleapis.com

To run the sample, you need to have the following roles:

* `Talent Solution Job Editor`
* `Talent Solution Profile Editor`
86 changes: 86 additions & 0 deletions talent/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
# Copyright 2020 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import os
import uuid

from google.api_core.exceptions import NotFound
import pytest

import job_search_create_company
import job_search_create_job
import job_search_create_tenant
import job_search_delete_company
import job_search_delete_job
import job_search_delete_tenant

PROJECT_ID = os.environ["GOOGLE_CLOUD_PROJECT"]


@pytest.fixture(scope="module")
def tenant():
tenant_ext_unique_id = "TEST_TENANT_{}".format(uuid.uuid4())
# create a temporary tenant
tenant_name = job_search_create_tenant.create_tenant(
PROJECT_ID, tenant_ext_unique_id
)

# extract company id
tenant_id = tenant_name.split("/")[-1]

yield tenant_id

try:
job_search_delete_tenant.delete_tenant(PROJECT_ID, tenant_id)
except NotFound as e:
print("Ignoring NotFound upon cleanup, details: {}".format(e))


@pytest.fixture(scope="module")
def company(tenant):
company_ext_id = "COMPANY_EXT_ID_{}".format(uuid.uuid4())

# create a temporary company
company_name = job_search_create_company.create_company(
PROJECT_ID, tenant, "Test Company Name", company_ext_id
)

# extract company id
company_id = company_name.split("/")[-1]

yield company_id

try:
job_search_delete_company.delete_company(PROJECT_ID, tenant, company_id)
except NotFound as e:
print("Ignoring NotFound upon cleanup, details: {}".format(e))


@pytest.fixture(scope="module")
def job(tenant, company):
post_unique_id = "TEST_POST_{}".format(uuid.uuid4().hex)[:20]
# create a temporary job
job_name = job_search_create_job.create_job(
PROJECT_ID, tenant, company, post_unique_id, "www.jobUrl.com"
)

# extract company id
job_id = job_name.split("/")[-1]

yield job_id

try:
job_search_delete_job.delete_job(PROJECT_ID, tenant, job_id)
except NotFound as e:
print("Ignoring NotFound upon cleanup, details: {}".format(e))
54 changes: 54 additions & 0 deletions talent/job_search_autocomplete_job_title.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# Copyright 2020 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# [START job_search_autocomplete_job_title]

from google.cloud import talent_v4beta1
import six


def complete_query(project_id, tenant_id, query):
"""Complete job title given partial text (autocomplete)"""

client = talent_v4beta1.CompletionClient()

# project_id = 'Your Google Cloud Project ID'
# tenant_id = 'Your Tenant ID (using tenancy is optional)'
# query = '[partially typed job title]'

if isinstance(project_id, six.binary_type):
project_id = project_id.decode("utf-8")
if isinstance(tenant_id, six.binary_type):
tenant_id = tenant_id.decode("utf-8")
if isinstance(query, six.binary_type):
query = query.decode("utf-8")

parent = f"projects/{project_id}/tenants/{tenant_id}"

request = talent_v4beta1.CompleteQueryRequest(
parent=parent,
query=query,
page_size=5, # limit for number of results
language_codes=["en-US"], # language code
)
response = client.complete_query(request=request)
for result in response.completion_results:
print(f"Suggested title: {result.suggestion}")
# Suggestion type is JOB_TITLE or COMPANY_TITLE
print(
f"Suggestion type: {talent_v4beta1.CompleteQueryRequest.CompletionType(result.type_).name}"
)


# [END job_search_autocomplete_job_title]
25 changes: 25 additions & 0 deletions talent/job_search_autocomplete_job_title_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Copyright 2020 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import os

import job_search_autocomplete_job_title

PROJECT_ID = os.environ["GOOGLE_CLOUD_PROJECT"]


def test_autocomplete_job_title(capsys, tenant):
job_search_autocomplete_job_title.complete_query(PROJECT_ID, tenant, "Software")
out, _ = capsys.readouterr()
assert "Suggested title:" in out
133 changes: 133 additions & 0 deletions talent/job_search_batch_create_jobs.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
# Copyright 2020 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# [START job_search_batch_create_jobs]

from google.cloud import talent
import six


def batch_create_jobs(
project_id,
tenant_id,
company_name_one,
requisition_id_one,
title_one,
description_one,
job_application_url_one,
address_one,
language_code_one,
company_name_two,
requisition_id_two,
title_two,
description_two,
job_application_url_two,
address_two,
language_code_two,
):
"""
Batch Create Jobs

Args:
project_id Your Google Cloud Project ID
tenant_id Identifier of the Tenant
"""

client = talent.JobServiceClient()

# project_id = 'Your Google Cloud Project ID'
# tenant_id = 'Your Tenant ID (using tenancy is optional)'
# company_name_one = 'Company name, e.g. projects/your-project/companies/company-id'
# requisition_id_one = 'Job requisition ID, aka Posting ID. Unique per job.'
# title_one = 'Software Engineer'
# description_one = 'This is a description of this <i>wonderful</i> job!'
# job_application_url_one = 'https://www.example.org/job-posting/123'
# address_one = '1600 Amphitheatre Parkway, Mountain View, CA 94043'
# language_code_one = 'en-US'
# company_name_two = 'Company name, e.g. projects/your-project/companies/company-id'
# requisition_id_two = 'Job requisition ID, aka Posting ID. Unique per job.'
# title_two = 'Quality Assurance'
# description_two = 'This is a description of this <i>wonderful</i> job!'
# job_application_url_two = 'https://www.example.org/job-posting/123'
# address_two = '111 8th Avenue, New York, NY 10011'
# language_code_two = 'en-US'

if isinstance(project_id, six.binary_type):
project_id = project_id.decode("utf-8")
if isinstance(tenant_id, six.binary_type):
tenant_id = tenant_id.decode("utf-8")
if isinstance(company_name_one, six.binary_type):
company_name_one = company_name_one.decode("utf-8")
if isinstance(requisition_id_one, six.binary_type):
requisition_id_one = requisition_id_one.decode("utf-8")
if isinstance(title_one, six.binary_type):
title_one = title_one.decode("utf-8")
if isinstance(description_one, six.binary_type):
description_one = description_one.decode("utf-8")
if isinstance(job_application_url_one, six.binary_type):
job_application_url_one = job_application_url_one.decode("utf-8")
if isinstance(address_one, six.binary_type):
address_one = address_one.decode("utf-8")
if isinstance(language_code_one, six.binary_type):
language_code_one = language_code_one.decode("utf-8")
if isinstance(company_name_two, six.binary_type):
company_name_two = company_name_two.decode("utf-8")
if isinstance(requisition_id_two, six.binary_type):
requisition_id_two = requisition_id_two.decode("utf-8")
if isinstance(title_two, six.binary_type):
title_two = title_two.decode("utf-8")
if isinstance(description_two, six.binary_type):
description_two = description_two.decode("utf-8")
if isinstance(job_application_url_two, six.binary_type):
job_application_url_two = job_application_url_two.decode("utf-8")
if isinstance(address_two, six.binary_type):
address_two = address_two.decode("utf-8")
if isinstance(language_code_two, six.binary_type):
language_code_two = language_code_two.decode("utf-8")
parent = f"projects/{project_id}/tenants/{tenant_id}"
uris = [job_application_url_one]
application_info = {"uris": uris}
addresses = [address_one]
jobs_element = {
"company": company_name_one,
"requisition_id": requisition_id_one,
"title": title_one,
"description": description_one,
"application_info": application_info,
"addresses": addresses,
"language_code": language_code_one,
}
uris_2 = [job_application_url_two]
application_info_2 = {"uris": uris_2}
addresses_2 = [address_two]
jobs_element_2 = {
"company": company_name_two,
"requisition_id": requisition_id_two,
"title": title_two,
"description": description_two,
"application_info": application_info_2,
"addresses": addresses_2,
"language_code": language_code_two,
}
jobs = [jobs_element, jobs_element_2]

operation = client.batch_create_jobs(parent=parent, jobs=jobs)

print("Waiting for operation to complete...")
response = operation.result(90)

print("Batch response: {}".format(response))


# [END job_search_batch_create_jobs]
Loading