custom imports from tuning step script - sagemaker pipelines - amazon-sagemaker

I have a tuning step in my sagemaker pipeline, in the following step i'm using train.py script inside the tuning step container. Inside the train.py script i'm using imported module called 'dill'. It seems that the sagemaker SKLearn container didn't install the requirements as it supposed to.
Running the pipeline followed with importing error:
ModuleNotFoundError: no module named 'dill'
My tuning step container:
sk_estimator = SKLearn(
entry_point="train.py",
role=role,
instance_count=1,
instance_type="ml.c5.xlarge",
source_dir="custom-model-sklearn/src/",
hyperparameters={
"target_col":'target_col',
"penalty": 'none',
"fit_intercept": True,
"solver": 'lbfgs',
"verbose": 0,
"C": 1,
},
py_version="py3",
framework_version="1.0-1",
script_mode=True,
sagemaker_session=pipeline_session,
disable_profiler=True,
output_path = "s3://{}/{}/TrainingStep".format(bucket,model_prefix)
)
base_job_name = f'sklearn-model'
The train.py script and the requirements.txt file which contains dill are inside the directory -
/custom-model-sklearn/src.
train.py:
import ...
import ...
.
.
import dill
.
.
requirements.txt:
dill
It seems that the source_dir is configured correctly due to the fact that the error is in the train.py script.
Currently i'm moving my code from one account to the another. In the previous account I did the same thing with the same hierarchy of directories and it did manage to install the module inside the tuning container.
Any help would be appreciated.

So it seems to use third parties libraries with Sagemaker estimator.
You can refer to this link to learn more about the process.
But basically with your code, add your requirements.txt file under the custom-model-sklearn/src/ and the estimator will install you required requirement when building the docker container.

Related

How can I automate supplying a version in appxmanifest?

I am using the desktop bridge for a WPF desktop application and am looking to automate the creation of my msix packages during build. I do not want to store any version information in source control.
The WPF project in the solution uses the gitversion msbuild task to automatically infer the version for my executable every time a build is done.
Unfortunately, I'm not sure if any such similar mechanism exists for .appxmanifest.
My thinking is that it would be nice to have this nicely integrated with the build process, similar to gitversion, but I haven't been able to find any documentation about what my options are during build or the Create App Packages process.
Perhaps there's some transform step during build that I'm not aware of that can be done to the .appxmanifest? Or maybe there's a way to have the version always reflect the version of the executable being bundled?
(MSDN forums question)
Your should modify the .appxmanifest file in your build pipeline before you create the package. After all, it's just a text-based XML file.
If you are using Azure Pipelines, you could accomsplish this using a Powershell task and a counter variable that gets incremented for each build:
pool:
vmImage: vs2017-win2016
variables:
buildPlatform: 'x86'
buildConfiguration: 'release'
major: 1
minor: 0
build: 0
revision: $[counter('rev', 0)]
steps:
- powershell: |
[Reflection.Assembly]::LoadWithPartialName("System.Xml.Linq")
$path = "Msix/Package.appxmanifest"
$doc = [System.Xml.Linq.XDocument]::Load($path)
$xName =
[System.Xml.Linq.XName]
"{http://schemas.microsoft.com/appx/manifest/foundation/windows10}Identity"
$doc.Root.Element($xName).Attribute("Version").Value =
"$(major).$(minor).$(build).$(revision)";
$doc.Save($path)
displayName: 'Version Package Manifest'
+Build, Package and Sign.
Please refer to this MSDN Magazine article for more information and a complete example of how to set up continuous integration (CI), continuous deployment (CD) and automatic updates of sideloaded MSIX packaged WPF applications using Azure Pipelines.
You must update the manifest before packaging. Check out this sample including a powershell script to poke the xml with the gitversion provided. https://github.com/microsoft/devops-for-windows-apps/blob/master/azure-pipelines.yml#L72

How to set Zeppelin interpreter dependencies via configuration

I'm trying to deploy zeppelin 0.7.3 and add ojdbc7.jar and custom jar dependencies automatically.
I'm wondering if there's a configuration item in zeppelin-env.sh or zeppelin-site.xml that could do this.
example:
copy zeppelin-0.7.3-bin-all to /data and copy ojdbc7.jar to /data/zeppelin-0.7.3-bin-all/jdbc/ojdbc7.jar
In interpreter, find spark, I can see dependencies/artifact added according to the configuration.
/data/zeppelin-0.7.3-bin-all/interpreter/jdbc/ojdbc7.jar

Exporting Octopus Deploy project doesn't create json file

I'm using Octo.exe 4.0.4 and Octopus version 3.4.12, and I'm trying to export a project from an Octopus Deploy server but I'm not getting an output file.
I can connect to the server, and list the projects, but when I run the export process it seems to stop at the point it should find the project group.
Here's a screenshot of the output.
I've tried running this from the machine which hosts the Octopus Server, as well as a tentacle, and I get identical results.
I've also tried not putting quotes around the project name and output file, since they aren't actually required here, and again same results.
According to the Octopus docn, the results should be something like this:
Octopus Deploy Command Line Tool, version 1.0.0.0
Handshaking with Octopus server: http://localhost/Octopus
Handshake successful. Octopus version: 2.4.4.43; API version: 3.0.0
Finding exporter 'project'
Beginning the export
Finding project: OctoFX Rate Service
Finding project group for project
Finding variable set for project
Finding deployment process for project
Finding NuGet feed for deployment process...
Finding NuGet feed for step Database
Finding NuGet feed for step Rate Service
Export file C:\tmp\OctoFX_Rate_Service.json successfully created.
It turns out this was a bug in Octo.exe v4.0.4.
It has been fixed in v4.0.7, and I can now export my project.

Error with module using Cloud Storage with Python and his tutorial

I'm trying to test Google Cloud Storage to store images (I need it in an app that I'm developing) and I'm following the Bookshelf App tutorial that they have in his webpage.
I'm using python and the problem is that when I execute the requirementes.txt all packages have been installed fine, but when I try execute the code, I see this error:
...sandbox.py", line 948, in load_module
raise ImportError('No module named %s' % fullname)
ImportError: No module named cryptography.hazmat.bindings._openssl
I have been trying hundred of posibles solutions, reinstalling only the cryptography package, trying to use different versions of the same module, and installing other packages that contains it but anything resolved the problem.
The requirements contains this:
Flask==0.10.1
gcloud==0.9.0
gunicorn==19.4.5
oauth2client==1.5.2
Flask-SQLAlchemy==2.1
PyMySQL==0.7.1
Flask-PyMongo==0.4.0
PyMongo==3.2.1
six==1.10.0
I'm sure that it is a simple error but I don't find the way to solve it.
Any help will be welcome. Thanks.
EDIT:
When I try do this with a python program this work fine:
import os
from gcloud import storage
os.environ['GOOGLE_APPLICATION_CREDENTIALS'] = 'key.json'
client = storage.Client(project='xxxxxxx')
bucket = client.get_bucket('yyyyyyy')
f = open('profile.jpg', 'rb')
blob = bucket.blob(f.name)
blob.upload_from_string(f.read(), 'image/jpeg')
url = blob.public_url
print url
Why I don't can use gcloud library without erros in a GAE app?
It seems you're following the bookshelf tutorial, but according to this line in your stacktrace:
...sandbox.py", line 948, in load_module
It hints that you're using dev_appserver.py to run the code. This isn't necessary for Managed VMs/Flexible unless you're using the compat runtime.
If this is the case, the tutorial provides correct instructions:
$ virtualenv env
$ source env/bin/activate
$ pip install -r requirements.txt
$ python main.py
(If this is not the case, please feel free to comment on this with more details about how you're running your application).

R Missing Package error when uploading to shinyapps.io

My Shiny program works fine locally on my PC (Windows 8, RStudio 0.99.489) but not when I upload it to shinyapps.io . I've tried 2 ways of packaging the data for upload - saveRDS on each object and save.image on the entire environment. Either way, when I upload it to shiny.io I get:
Preparing to deploy application...DONE
Uploading bundle for application: 77966...DONE
Deploying bundle: 350891 for application: 77966 ...
Waiting for task: 132618597
building: Parsing manifest
building: Building image: 344796
building: Installing packages
################################ Begin Task Log ################################
[2016-01-16T22:19:45.818533554+0000] Installing R package: magrittr (1.5)
Error in library(stylo) : there is no package called �stylo�
Execution halted
################################# End Task Log #################################
Error: Unhandled Exception: Child Task 132618599 failed: Error building image: Build exited with non-zero status: 1
Execution halted
It seems that Shiny isn't aware of the Stylo package. I tried to install it in my code, but that didn't help.
1. Does Shiny have all R packages?
2. If not, is there a list of which packages are available?
Thanks very much.
Are you including the stylo package at the top of your server.R file via library("stylo")? If you are doing that and it's giving you the error, try using require("stylo") instead.
From the docs, the rsconnect package is supposed to automatically detect what packages are necessary for your app. Probably worth a read (if you haven't already) just to be sure you're following everything correctly in order for rsconnect to do its job.
I solved the problem by doing a clean build of my environment -- imported data tables and functions from RDS files only, and carefully avoided references to unnecessary packages. I recreated the one function I needed from Stylo locally, so that I could be certain I wouldn't require it.

Resources